0

I've been using Jupyter notebooks (installed with Anaconda running python3.5) on Mac OSX 10.10.5. I followed instructions here to install a python2.7 kernel as well, which I can select via a drop down menu in the Jupyter notebook.

Both kernels seem to work, except when it comes to importing packages. I can import all of the usual packages when using the python3 kernel (numpy, matplotlib, etc), but not when I am using the python2 kernel. In python2 I get a message along the lines of:

ImportError                               Traceback (most recent call last)
<ipython-input-1-4ee716103900> in <module>()
----> 1 import numpy as np

ImportError: No module named numpy

How can I ensure that the python2 kernel sees the packages I have installed?

I'm fairly new to python and don't know a lot about the underlying installation and framework, so I'm not sure how to access the relevant path variables which might give me a clue as to what's going wrong. I found a lot suggestions online about installing packages or installing a second kernel in Jupyter, but none seem to address the problems I'm having.

Community
  • 1
  • 1
hughes
  • 27
  • 3
  • 1
    You have to install packages in python2 independently of python3, then it'll work. – Phlya May 30 '16 at 15:20
  • See Phlya's point. In fact the differences in availability and testing of packages is the main reason many still stay with Python 2.7. The older packages have been around for a long time and trust needs to be built that the newer 3x versions work just as well. – roadrunner66 May 30 '16 at 18:10
  • After uninstalling anaconda, I tried it in reverse order (installing anaconda for python2 and then activating the python3 environment). Now I can access packages in the python2 kernel but not the python3 kernel. I tried to install the packages using `pip3 install numpy` which seemed successful (I can access them in a terminal session) but I still can't access them in Jupyter. For some reason Jupyter cannot see that the packages are installed. – hughes May 30 '16 at 22:06

0 Answers0