Python Packages not showing up after pip install

Viewed 430

Error


---------------------------------------------------------------------------
ModuleNotFoundError                       
Traceback (most recent call last)
C:\Users\JOEYCH~1\AppData\Local\Temp/ipykernel_17484/1544913177.py in <module>
----> 1 import basemap

ModuleNotFoundError: No module named 'basemap'

Hi all,

I am new to python and I kept reading other forums but nothing seems to work.

I currently am using a jupyter notebook through anaconda. I am having trouble installing packages.

I have tried creating a new environment, activating that environment and installing packages through the PowerShell terminal. Even though the terminal says the packages (geopy and jupyter) are installed when I run conda list, I still am getting the no module found error.

I have tried installing the packages directly in jupyter notebook with the following code but I receive the following error:

ModuleNotFoundError                       
Traceback (most recent call last)
C:\Users\JOEYCH~1\AppData\Local\Temp/ipykernel_11232/996305698.py in <module>
      3 import sys
      4 get_ipython().system('{sys.executable} -m pip install basemap')
----> 5 import basemap

ModuleNotFoundError: No module named 'basemap

I have added the environment to my jupyter notebook and it shows up so I can switch the kernel to the new environment. Code I used to add my environment to jupyter notebook


$ipython kernel install --name "local-venv-kernel" --user```
1 Answers

I am not familiar with the get_ipython function. I think you should try

import sys
!{sys.executable} -m pip install basemap

OR

import sys
!conda install --yes --prefix {sys.prefix} basemap

depending if you want to use pip or conda as package manager.

From From Conda docs

--yes: Do you want to instal Y/N] confirmation.
--prefix: [Specify] Full path to environment location

From sys doc

sys.prefix: Path to environment location.

Related