Registry / analytics / policyengine-core

policyengine-core

JSON →
library3.27.0pypypi✓ verified 86d ago

Core microsimulation engine enabling country-specific policy models. Current version 3.27.0, release cadence approximately biweekly.

pip install policyengine-core
INSTALL
IMPORT
SIG · POLICYENGINE-CORE
P
policyengine-core
analyticspythonv3.27.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Microsimulation
from policyengine_core import Microsimulation
from policyengine import Microsimulation
API namespace changed in v2
Simulation
from policyengine_core import Simulation
from policyengine_core.simulations import Simulation
Direct import from top-level preference
CountryTaxBenefitSystem
from policyengine_core.countries import CountryTaxBenefitSystem
IndividualSim
from policyengine_core import IndividualSim
PopulationSim
from policyengine_core import PopulationSim

Create a microsimulation for the UK, add a person, and calculate income tax.

from policyengine_core import Microsimulation # Create a microsimulation with a single person sim = Microsimulation(country='uk', year=2023) sim.add_person(name='person1', age=30, employment_income=30000) sim.build() # Compute a variable income_tax = sim.calculate('income_tax', map_to='person') print(income_tax)
Debug
Known issues
breakingThe import path changed in v2 from `policyengine` to `policyengine_core`. Old code using `import policyengine` will break.
fix
Change imports to `from policyengine_core import ...`.
affects: <2.0.0
deprecatedThe `Simulation` class is deprecated in favour of `Microsimulation`. `Simulation` may be removed in a future version.
fix
Use `Microsimulation` instead.
affects: >=3.0.0
gotchaThe `year` parameter must be an integer; passing a string will cause a TypeError.
fix
Always pass year as an integer, e.g., `year=2023`.
affects: >=3.0.0
Errors
Common errors & fixes
ImportError: cannot import name 'Microsimulation' from 'policyengine_core'
Outdated policyengine-core version (<3.0.0) where Microsimulation was not yet introduced.
fix
Upgrade to the latest version: `pip install --upgrade policyengine-core`.
TypeError: 'str' object cannot be interpreted as an integer
Passing a string for the `year` parameter instead of an integer.
fix
Change `year='2023'` to `year=2023`.
ValueError: Country 'us' not supported. Available countries: ['uk']
Attempting to use a country model that is not installed.
fix
Install the required country package, e.g., `pip install policyengine-us`.
Upgrade
Version history
3.27.0latest on PyPI · released Jun 4, 2026
Audit
Dependencies
policyengine-ukoptionalCountry-specific model for the UK
policyengine-usoptionalCountry-specific model for the US
Agent activity
31 hits · last 30 days
node
28
OpenAI (training)
1
Resources
policyengine-core — pip install policyengine-core · libregistry