emax
emax

Reputation: 7245

Python: I can import packages in python but not in the notebook

I have installed two packages such as mgwr and libpysal.

I can import them using a normal python script but when I try to import in my jupyter notebook I get the error that the modules don't exist

import libpysal as ps
ImportError: No module named libpysal

from mgwr.gwr import GWR, MGWR
ImportError: No module named mgwr

if I do from Terminal

! which python 
/usr/local/opt/python/libexec/bin/python

from the notebook

! which python
/Users/myName/anaconda2/bin/python

Upvotes: 0

Views: 262

Answers (1)

BHC
BHC

Reputation: 989

You might need to get your system to look for the anaconda version of Python by telling it where it's located.

cd ~
nano .bashrc

Now add export PATH="/home/<myName>/anaconda2/bin:$PATH" to the end of the file.

You can now refresh the PATH variable by using source or .

. .bashrc

Hopefully which python now points to your anaconda folder. If it does, go ahead and conda install the packages that Jupyter isn't finding. If not, leave a comment.

Upvotes: 3

Related Questions