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)
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.
fixUpgrade 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.
fixChange `year='2023'` to `year=2023`.
ValueError: Country 'us' not supported. Available countries: ['uk']
Attempting to use a country model that is not installed.
fixInstall 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