-
Notifications
You must be signed in to change notification settings - Fork 163
Open
Description
Expected Behavior
When using the command to run my app:
python -m solara run moving_agents.py
it should start normally
Current Behavior
It throws this error
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/home/costi/Documents/MAS/Lab 1/.venv/lib/python3.12/site-packages/solara/__main__.py", line 16, in <module>
from uvicorn.main import LEVEL_CHOICES, LOOP_CHOICES
ImportError: cannot import name 'LOOP_CHOICES' from 'uvicorn.main' (/home/costi/Documents/MAS/Lab 1/.venv/lib/python3.12/site-packages/uvicorn/main.py). Did you mean: 'LEVEL_CHOICES'?
I fixed it by adding this in uvicorn/main.py
LOOP_CHOICES = click.Choice(['critical', 'error', 'warning', 'info', 'debug', 'trace', 'auto'])
Steps to Reproduce the Problem
No specific steps to follow. I was just trying to run this code:
import mesa
from mesa.visualization import SolaraViz, make_space_component
NUM_AGENTS = 10
GRID_SIZE = 10
SEED = 42
class MovingAgent(mesa.Agent):
def __init__(self, model):
super().__init__(model)
def step(self):
neighbors = self.model.grid.get_neighborhood(self.pos,
moore = False, # no diagonals
include_center = False,
radius = 1)
new_pos = self.random.choice(neighbors)
self.model.grid.move_agent(self, new_pos)
class GridModel(mesa.Model):
def __init__(self,
num_agents = NUM_AGENTS,
grid_size = GRID_SIZE,
seed = SEED):
super().__init__(seed = seed)
self.grid = mesa.space.MultiGrid(grid_size, grid_size, torus = False)
for _ in range(num_agents):
empty_cells = [(x, y) for (cell_content, (x, y)) in self.grid.coord_iter()
if len(cell_content) == 0]
init_pos = self.random.choice(empty_cells)
a = MovingAgent(self)
self.grid.place_agent(a, init_pos)
def step(self):
self.agents.shuffle_do('step')
def agent_portrayal(agent):
return{
'color' : 'blue',
'size' : 100,
'marker' : 'o'
}
if __name__ == '__main__':
model_params = {
'grid_size' : {
'type' : 'SliderInt',
'value' : GRID_SIZE,
'label' : 'Grid Size',
'min' : 4,
'max': 16,
'step' : 1
},
'num_agents' : {
'type' : 'SliderInt',
'value' : NUM_AGENTS,
'label' : 'Number of Agents',
'min' : 4,
'max' : 16,
'step' : 1
}
}
my_model = GridModel()
grid_component = make_space_component(agent_portrayal = agent_portrayal)
page = SolaraViz(
model = my_model,
components = [grid_component],
model_params = model_params,
name = 'Moving Agents'
)
page
requirements.txt
altair==5.5.0
anyio==4.11.0
asttokens==3.0.0
attrs==25.3.0
cachetools==6.2.0
certifi==2025.8.3
charset-normalizer==3.4.3
click==8.3.0
comm==0.2.3
contourpy==1.3.3
cycler==0.12.1
debugpy==1.8.17
decorator==5.2.1
executing==2.2.1
fastjsonschema==2.21.2
filelock==3.19.1
fonttools==4.60.1
h11==0.16.0
humanize==4.13.0
idna==3.10
ipykernel==6.30.1
ipython==9.6.0
ipython_pygments_lexers==1.1.1
ipyvue==1.11.3
ipyvuetify==1.11.3
ipywidgets==8.1.7
jedi==0.19.2
Jinja2==3.1.6
jsonschema==4.25.1
jsonschema-specifications==2025.9.1
jupyter_client==8.6.3
jupyter_core==5.8.1
jupyterlab_widgets==3.0.15
kiwisolver==1.4.9
Markdown==3.9
markdown-it-py==4.0.0
MarkupSafe==3.0.3
matplotlib==3.10.6
matplotlib-inline==0.1.7
mdurl==0.1.2
Mesa==3.3.0
narwhals==2.6.0
nbformat==5.10.4
nest-asyncio==1.6.0
networkx==3.5
numpy==2.3.3
packaging==25.0
pandas==2.3.3
parso==0.8.5
pexpect==4.9.0
pillow==11.3.0
platformdirs==4.4.0
prompt_toolkit==3.0.52
psutil==7.1.0
ptyprocess==0.7.0
pure_eval==0.2.3
Pygments==2.19.2
pymdown-extensions==10.16.1
pyparsing==3.2.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.3
pyzmq==27.1.0
reacton==1.9.1
referencing==0.36.2
requests==2.32.5
rich==14.1.0
rich-click==1.9.1
rpds-py==0.27.1
scipy==1.16.2
six==1.17.0
sniffio==1.3.1
solara==1.51.1
solara-server==1.51.1
solara-ui==1.51.1
stack-data==0.6.3
starlette==0.48.0
tornado==6.5.2
tqdm==4.67.1
traitlets==5.14.3
typing_extensions==4.15.0
tzdata==2025.2
urllib3==2.5.0
uvicorn==0.37.0
watchdog==6.0.0
watchfiles==1.1.0
wcwidth==0.2.14
websockets==15.0.1
widgetsnbextension==4.0.14
Specifications
- Solara Version: 1.51.1
- Platform: Debian 13
- Affected Python Versions: 3.12
Metadata
Metadata
Assignees
Labels
No labels