Registry / data / simpy
library4.1.2pypypi✓ verified 84d ago

SimPy is a process-based discrete-event simulation framework based on standard Python. Processes in SimPy are defined by Python generator functions and can, for example, be used to model active components like customers, vehicles or agents. SimPy also provides various types of shared resources to model limited capacity congestion points (like servers, checkout counters and tunnels). It is currently at version 4.1.1 and follows an active release cadence with regular updates.

pip install simpy
INSTALL
IMPORT
SIG · SIMPY
S
simpy
datapythonv4.1.2
Install
1.5s avg
Import
112ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.117s · 18MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.5s · import 0.106s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

Environment
import simpy env = simpy.Environment()
The core simulation environment.
Resource
from simpy import Environment, Resource
Common shared resource for modeling limited capacity.
Container
from simpy import Environment, Container
Resource for modeling discrete quantities of a substance.
Store
from simpy import Environment, Store
Resource for storing and retrieving arbitrary Python objects.

This quickstart demonstrates a simple 'car' process that alternately parks and drives. It showcases environment creation, defining a process as a generator function, scheduling the process, and running the simulation for a specified duration. The `env.timeout()` event is used to simulate the passage of time.

import simpy def car(env): while True: print(f'Start parking at {env.now}') parking_duration = 5 yield env.timeout(parking_duration) print(f'Start driving at {env.now}') trip_duration = 2 yield env.timeout(trip_duration) env = simpy.Environment() env.process(car(env)) env.run(until=15)
Debug
Known issues
breakingSimPy 4.0 dropped support for Python 2.7 and requires Python 3.6+ (Python 3.8+ for 4.1.x). `BaseEnvironment` was removed; users should inherit from `Environment` instead.
fix
Ensure Python >= 3.8. Replace `simpy.BaseEnvironment` with `simpy.Environment`. Update imports and code accordingly.
affects: >=4.0.0
breakingIn SimPy 4.0, the `Environment.exit()` method and `StopProcess` exception were eliminated. Process generators that need to return a value or exit early must now use the standard Python `return` keyword.
fix
Replace `env.exit(value)` or `raise simpy.exceptions.StopProcess(value)` with `return value` within generator functions.
affects: >=4.0.0
breakingSimPy 3.x introduced a major API overhaul from SimPy 2.x. Processes no longer needed to subclass `Process` and now yield event objects directly (e.g., `yield env.timeout(1)` instead of `yield hold, self, 1`).
fix
Rewrite process functions to be generator functions that yield event objects from the environment (e.g., `env.timeout()`, `resource.request()`). Consult the SimPy 2 to 3 porting guide if migrating older code.
affects: >=3.0.0
gotchaSimPy is a discrete-event simulation library. It is not designed for continuous simulations or fixed-step simulations where processes do not interact or use shared resources. Using it for such scenarios can be overkill or lead to unidiomatic code.
fix
Ensure your problem fits a discrete-event, process-based model with interacting components. For fixed-step or continuous simulations without complex interactions, other tools might be more suitable.
affects: All
gotchaSimPy processes are Python generator functions. Understanding `yield` is crucial; it suspends a process until an event occurs, returning control to the simulation. Misunderstanding generator execution flow can lead to logical errors.
fix
Familiarize yourself with Python generators and coroutines. Remember that code within a process generator only executes up to a `yield` statement, then resumes when the yielded event is processed.
affects: All
Errors
Common errors & fixes
TypeError: 'function' object is not an iterator
This error occurs when `env.process()` is called with a function object itself, instead of a generator object obtained by calling the function with its arguments.
fix
Call the process function with its arguments when passing it to `env.process()` to create a generator object.  
```python
import simpy

def my_process(env):
    yield env.timeout(1)

env = simpy.Environment()
env.process(my_process(env)) # Correct: call the function
env.run()
```
AttributeError: 'Container' object has no attribute 'request'
This error occurs when a SimPy `Container` is mistakenly treated as a `Resource`, attempting to call the `request()` method which does not exist on a `Container` object.
fix
Use `simpy.Resource` for managing discrete resource units (like servers or machines) with `request()` and `release()` methods. For `simpy.Container`, use `get()` and `put()` to manage quantities.  
```python
import simpy

env = simpy.Environment()
resource = simpy.Resource(env, capacity=1) # Use simpy.Resource for request/release

def process(env, res):
    with res.request() as req:
        yield req
        print(f'{env.now}: Resource obtained!')

env.process(process(env, resource))
env.run()
```
TypeError: 'coroutine' object is not an iterator
This error occurs when an `async def` (coroutine) function is passed to `env.process()`. SimPy expects a traditional generator function (defined with `def` and containing `yield`), not Python's `async/await` syntax.
fix
Rewrite the process function using a standard `def` and `yield` for SimPy events, instead of `async def` and `await`.  
```python
import simpy

def my_process(env): # Standard generator function
    print(f'{env.now}: Process started')
    yield env.timeout(1) # Use yield for SimPy events
    print(f'{env.now}: Process finished')

env = simpy.Environment()
env.process(my_process(env))
env.run()
```
Upgrade
Version history
4.1.2latest on PyPI · released May 24, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
35 hits · last 30 days
node
29
OpenAI (training)
1
Resources
simpy — pip install simpy · libregistry