ModuleNotFoundError: No module named 'shapely'

Summary

When i run my code on local, I have the error “ModuleNotFoundError: No module named ‘shapely’”

I use this package for coords and polygons.

I built the code with shapely before to built interface with streamlit. Everything was okay. I followed the discusses about this type of issue :

Uninstalled and re-installed the package shapely
Add a requirements.txt with the package in the root of the project.
Tried to set up a new virtual environnement

But still have the error and streamlit doesn’t run the algorythm.

Code snippet:

ModuleNotFoundError: No module named 'shapely'
Traceback:
File "c:\users\chris\appdata\local\programs\python\python39\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 563, in _run_script
    exec(code, module.__dict__)
File "C:\Users\chris\PycharmProjects\EnqueteImmobiliere\main.py", line 27, in <module>
    RetrieveMap.retrieve_communes(lat, long, traj, trajet_duree)
File "C:\Users\chris\PycharmProjects\EnqueteImmobiliere\RetrieveMap.py", line 13, in retrieve_communes
    import shapely
![Capture d’écran 2022-12-28 233124|690x454](upload://vFFYdmUeEtAvst3MJFprSTKUrhU.png)

Can somebody help me with it ?

Debug info

  • Streamlit version: (get it with 1.16 streamlit version)
  • Python version: tried with python 3.7, python 3.9 and python 3.10
  • Using PyCharm

Requirements file

streamlit==1.16.0
pandas==1.1.5
shapely==2.0.0

If you get the error locally, you’ll need to make sure you are running Streamlit in the same environment where the packages are installed. Your local workspace might not be configured to spin up environments automatically from your requirements file.

So, are you showing shapely installed in your base environment or some other? Are you executing streamlit run my_app.py from that same environment? If you are not sure, I would try making a new environment with a distinct name. Then you can see in the terminal via a (my_env) prefix which environment your are in.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.