Skip to content Skip to sidebar Skip to footer

Jupyter Notebook, ImportError: No Module Named Pylab

I am a ubuntu user, and I have install python 2.7.9 on my computer. In order to use jupyter notebook, I down load anaconda2. After my installation, I find after entering the comman

Solution 1:

I find the problem.

In terminal:

ipython
In [1]: import sys

In [2]: sys.path
Out[2]: 
['',
 '/home/hust/anaconda2/bin',
 '/home/hust/anaconda2/lib/python27.zip',
 '/home/hust/anaconda2/lib/python2.7',
 '/home/hust/anaconda2/lib/python2.7/plat-linux2',
 '/home/hust/anaconda2/lib/python2.7/lib-tk',
 '/home/hust/anaconda2/lib/python2.7/lib-old',
 '/home/hust/anaconda2/lib/python2.7/lib-dynload',
 '/home/hust/.local/lib/python2.7/site-packages',
 '/home/hust/anaconda2/lib/python2.7/site-packages',
 '/home/hust/anaconda2/lib/python2.7/site-packages/Sphinx-1.3.5-py2.7.egg',
 '/home/hust/anaconda2/lib/python2.7/site-packages/setuptools-20.3-py2.7.egg',
 '/home/hust/.local/lib/python2.7/site-packages/IPython/extensions',
 '/home/hust/.ipython']

But in jupyter notebook, the sys.path is:

 ['',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python27.zip',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/plat-linux2',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/lib-tk',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/lib-old',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/lib-dynload',
  '/home/hust/.local/lib/python2.7/site-packages',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/site-packages/setuptools-20.7.0-py2.7.egg',
  '/home/hust/anaconda2/envs/ipykernel_py2/lib/python2.7/site-packages',
  '/home/hust/.local/lib/python2.7/site-packages/IPython/extensions',
  '/home/hust/.ipython']

Then I remember I have used the following codes to create a python2 kernel.

conda create -n ipykernel_py2 python=2 ipykernel
source activate ipykernel_py2    
python -m ipykernel install --user

In the website's description, if you’re running Jupyter on Python 3, you can set up a Python 2 kernel like this. But actually I am running Jupyter on Python 2, the reason why I could not new a python2 script in jupyter notebook should be something else.

Finally, I realize that it is better to master all the pythons' environment via pyenv. I should firstly install pyenv and then I only need use these commands, pyenv install anaconda-2.4.0 , pyenv global anaconda-2.4.0 and jupyter notebook.


Post a Comment for "Jupyter Notebook, ImportError: No Module Named Pylab"