0

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
4
  • Is your notebook using the same install of Python as your running your .pys with? Commented Feb 22, 2019 at 14:30
  • To check, try ! which python in Jupyter and check that the output is the same as which python in the terminal where you run your script. Commented Feb 22, 2019 at 14:32
  • @BHC I added it in the question Commented Feb 22, 2019 at 14:36
  • whats the output of echo $PATH in terminal? Commented Feb 22, 2019 at 15:01

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I thing that I did not understand how to do it. The file .baschrc is empty
Did you spell it right or was that just a typo in your comment? Should be .bashrc. If you did, did you change to your home directory (cd ~)? And can you send the output of echo $PATH?
Did it. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.