0

I face import error when trying to import shapely module. It was successfully installed by the conda install -c conda-forge shapely. Moreover, I've tried to reproduce it with pip and got

Requirement already satisfied: shapely in /opt/miniconda3/envs/Nerkan_env_new3/lib/python3.7/site-packages (1.7.1)

However I am getting the error

File "/mnt/mipt_storage01/user7/QS/tsp/TSP.py", line 3, in <module>
from shapely.geometry import LineString
ModuleNotFoundError: No module named 'shapely'

I've specified the interpeters in all use files as #!/opt/miniconda3/bin/envs/Nerkan_env_new3/python, where my env interpreter is stored, and os.environ['CONDA_DEFAULT_ENV'] returns the correct name Nerkan_env_new3. So I wonder what is the issue with the package importing?

Nourless
  • 729
  • 1
  • 5
  • 18
  • Can you try `pip list | grep shapely` and see if the module appears as installed? – angelogro Oct 08 '21 at 17:36
  • @angelogro, well it is actually doesn't appear there. I've removed it and reinstalled with pip and it was still not there. In the end it was the name of the package, in pip list it is 'Shapely'. That module was found by your command, but changing the name didn't help, it is still `ModuleNotFoundError: No module named 'Shapely'`, while `grep` shows `Shapely 1.7.1` – Nourless Oct 08 '21 at 17:49
  • 1
    Are you sure, your interpreter is running in the expected environment? According to [this thread](https://stackoverflow.com/questions/53952214/how-can-i-find-out-which-python-virtual-environment-i-am-using), you can find out your environment base folder by running `print(sys.prefix)`. – angelogro Oct 08 '21 at 17:56
  • 1
    @angelogro, it gives me `/opt/miniconda3`. Is it correct or I should expect something like `opt/miniconda3/bin/envs/Nerkan_env_new3`? – Nourless Oct 08 '21 at 18:01
  • I actually never used _miniconda_. Are you sure `#!/opt/miniconda3/bin/envs/Nerkan_env_new3/python` makes sure that a specific interpreter is used? Did you activate the desired environment before running the file? – angelogro Oct 08 '21 at 18:38
  • @angelogro , yes, I activated it before run. Also, as I mentioned, the call of `os.environ['CONDA_DEFAULT_ENV']` gives my environment so I think it should be ok. – Nourless Oct 08 '21 at 18:41

0 Answers0