Failed to import module from Python laptop into Jupyter

I have an environment in which I started using Anaconda and I successfully installed the module in it. I know this because I can run python and then import tensorflow . This also works when through ipython . The problem is that I can not load the module from the laptop, which started using either ipython notebook or jupyter (although I am running either from the active environment).

I suspect it relates to configuring ipython , but I don't know how to debug and solve the problem. Any idea?

Edit: Here are the steps I took:

  • conda create --name tensorflowproblem python=2.7 to create an environment
  • source activate tensorflowproblem
  • conda install --name tensorflowproblem jupyter to install jupyter
  • pip install https://storage.googleapis.com/tensorflow/mac/tensorflow-0.5.0-py2-none-any.whl to install tensorflow

Location pip and jupyter :

 $ which -a pip /Users/dror/anaconda/envs/tensorflowproblem/bin/pip $ which -a jupyter /Users/dror/anaconda/envs/tensorflowproblem/bin/jupyter 

Note that there is a directory ~/anaconda/envs/tensorflowproblem/lib/python2.7/site-packages/tensorflow .

In addition, neither python -c "import tensorflow" nor ipython -c "import tensorflow" any errors.

In accordance with the request also exhibited

 $ conda list -n tensorflowproblem # packages in environment at /Users/dror/anaconda/envs/tensorflowproblem: # appnope 0.1.0 py27_0 backports-abc 0.4 <pip> backports.ssl-match-hostname 3.4.0.2 <pip> backports_abc 0.4 py27_0 decorator 4.0.4 py27_0 freetype 2.5.5 0 ipykernel 4.1.1 py27_0 ipython 4.0.0 py27_1 ipython-genutils 0.1.0 <pip> ipython_genutils 0.1.0 py27_0 ipywidgets 4.1.0 py27_0 jinja2 2.8 py27_0 jsonschema 2.4.0 py27_0 jupyter 1.0.0 py27_0 jupyter-client 4.1.1 <pip> jupyter-console 4.0.3 <pip> jupyter-core 4.0.6 <pip> jupyter_client 4.1.1 py27_0 jupyter_console 4.0.3 py27_0 jupyter_core 4.0.6 py27_0 libpng 1.6.17 0 markupsafe 0.23 py27_0 mistune 0.7.1 py27_0 nbconvert 4.0.0 py27_0 nbformat 4.0.1 py27_0 notebook 4.0.6 py27_0 numpy 1.10.1 <pip> openssl 1.0.2d 0 path.py 8.1.2 py27_1 pexpect 3.3 py27_0 pickleshare 0.5 py27_0 pip 7.1.2 py27_0 ptyprocess 0.5 py27_0 pygments 2.0.2 py27_0 pyqt 4.11.4 py27_0 python 2.7.10 2 python.app 1.2 py27_4 pyzmq 14.7.0 py27_1 qt 4.8.7 1 qtconsole 4.1.0 py27_0 readline 6.2 2 setuptools 18.5 py27_0 simplegeneric 0.8.1 py27_0 singledispatch 3.4.0.3 py27_0 sip 4.16.9 py27_0 six 1.10.0 py27_0 sqlite 3.8.4.1 1 ssl_match_hostname 3.4.0.2 py27_0 tensorflow 0.5.0 <pip> terminado 0.5 py27_1 tk 8.5.18 0 tornado 4.3 py27_0 traitlets 4.0.0 py27_0 wheel 0.26.0 py27_1 zeromq 4.1.3 0 zlib 1.2.8 0 

Also, as requested, the output from sys.path :

 ['', '/Users/user/anaconda/envs/py2/lib/python27.zip', '/Users/user/anaconda/envs/py2/lib/python2.7', '/Users/user/anaconda/envs/py2/lib/python2.7/plat-darwin', '/Users/user/anaconda/envs/py2/lib/python2.7/plat-mac', '/Users/user/anaconda/envs/py2/lib/python2.7/plat-mac/lib-scriptpackages', '/Users/user/anaconda/envs/py2/lib/python2.7/lib-tk', '/Users/user/anaconda/envs/py2/lib/python2.7/lib-old', '/Users/user/anaconda/envs/py2/lib/python2.7/lib-dynload', '/Users/user/anaconda/envs/py2/lib/python2.7/site-packages', '/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/Sphinx-1.3.1-py2.7.egg', '/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/aeosa', '/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/setuptools-17.1.1-py2.7.egg', '/Users/user/anaconda/envs/py2/lib/python2.7/site-packages/IPython/extensions', '/Users/user/.ipython'] 
+9
python ipython-notebook jupyter anaconda
Nov 27 '15 at 2:59
source share
4 answers

Try the following:

 source activate tensorflowproblem conda install notebook ipykernel ipython kernel install --user 

It looks like your tensor env problem does not have an ipython kernel, but there is another (possibly your root) env. When you start Jupyter, it puts you in env with the kernel, but without the tensorflow package. If you have not yet run the above lines, you can test this theory by opening a laptop and working:

 import sys sys.path 

If the first few paths do not display "envs / tensorflowproblem" as part of them, this explains the problem.

+11
Apr 14 '16 at 3:41
source share

For jupyter laptop, the following python package is useful for managing the python / anaconda kernel environment to run the laptop using:

 pip install environment_kernels 

Run this installation either in the default environment or in a specific one. After running jupyter notebook you should see the options for your anaconda environment in two places:

  • options to launch a new laptop
  • in the kernel > change kernel drop-down list for an existing laptop.

For more information, I found this post helpful!

+2
Oct 06 '16 at 15:29
source share

Most likely, your laptop did not load the correct kernel (environment). The environment name is displayed in the upper right corner. See the red circle in the image below. If this is not the case, click "Kernel β†’ Change Kernel" and select the appropriate kernel.

enter image description here

+1
Nov 30 '16 at 16:43
source share

From my experience with the xlrd module running in the console and not in Jupyter, you can try going to your system Python folder /usr/local/bin/ and then looking for the python version. Then use the pipXX file to install the required module.

0
Feb 21 '17 at 14:13
source share



All Articles