Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in extracting agent from GeoSpace.agents in tutorial using Spyder #193

Open
whitbern opened this issue Mar 14, 2024 · 6 comments
Open

Comments

@whitbern
Copy link

this is an attachment of the script mesa_geo_tutorial.txt
this is a screenshot of the error error_mesa_geo_tutorial

Good evening, currently, I am doing the tutorial for Mesa-geo using Spyder. When I try to extract the agents using this line:

agent = m.space.agents[0]

I get a TypeError stating that: 'type' object is not subscriptable. Before that, I get a "Coordinate = tuple[int, int]." However, when I look at the mesa.space module, they mention lists?

I would expect for this just to give me the first agent from the listed url.

Thankfully this works just fine in Jupyter Notebook. Can you all help me figure out why this is not working in Spyder?
Thanks!

@wang-boyu
Copy link
Member

Thanks for sharing the code and screenshot. The error appears to be from type hints. Can I ask which version of Python you were using?

Mesa & Mesa-Geo require Python 3.9 and above. I couldn't reproduce the error with Python 3.10. Perhaps try to recreate a clean virtual environment with Python 3.9 or above, install Mesa-Geo and try again?

@EwoutH
Copy link
Member

EwoutH commented Mar 21, 2024

This is indeed an error caused by new syntax introduced in Python 3.9. Upgrading should resolve the problem.

@wang-boyu the more interesting problem is how users manage to install Mesa-geo with incompatible Python versions. Have we set our Python requirements correctly in this repo? https://packaging.python.org/en/latest/guides/dropping-older-python-versions/#specify-the-version-ranges-for-supported-python-distributions

@wang-boyu
Copy link
Member

wang-boyu commented Mar 21, 2024

Python requirement is specified in the setup.cfg file:

python_requires = >=3.9
I suppose it should work as expected...?

Edit: in python 3.8 I could only install mesa-geo 0.8.0. When attempting to install 0.9.0, there is an error message indicating python >= 3.9 is required, which is as expected.

@EwoutH
Copy link
Member

EwoutH commented Mar 21, 2024

Yes, this is indeed the case and it's configured correctly: https://github.com/EwoutH/mesa/actions/runs/8379466683

@whitbern which version of mesa-geo are you using and which Python version? How did you install mesa-geo?

@whitbern
Copy link
Author

Hello--I have Python 3.11.5 I have the latest version of mesa-geo: 0.7.0. I installed mesa-geo using these commands for Windows in the Anaconda Prompt:

conda install fiona pyproj rtree shapely
pip install mesa-geo

@EwoutH
Copy link
Member

EwoutH commented Mar 21, 2024

Right, I read the error wrongly. Seems like an issue in the GeoSpace or the mesa space itself.

  1. Which mesa version are you using?
  2. Could you print m.space.agents and its type.
  3. Could you update to the latest versions of both mesa and mesa-geo and see if this error still persists?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants