Notebook: Import Errors on Jupyter notebook ; while spyder (from Anaconda) Works Fine on Mac OS

Created on 30 Jun 2016  路  5Comments  路  Source: jupyter/notebook

Hi everyone!

I'm new to python, and learning Tensorflow recently. I've successfully installed Anaconda on my Mac OS (Python version: 2.7.11). Then I installed Tensorflow by following the official guide from tensorflow.org (by installation method: "Anaconda Installation" ).

Then I open the spyder (from anaconda), and run some lines of codes, everything goes fine. Tensorflow, as well as other modules can be successfully imported. While I open the Jupyter notebook (also from anaconda), tensorflow can be imported too, but some other modules, like matplotlib, scipy... cannot be imported, I keep receiving message: "error: no module name XXX"

I searched on web and found the same problem has been encountered previously by others: #https://github.com/jupyter/notebook/issues/1524
@carreau @takluyver @thirumalaipm have posted valuable information but I still cannot solve the problem.

Then I checked the system and found:
In spyder, sys.executable is "/Users/abc/anaconda/bin/python";
In Jupyter, sys.executable is "/Users/abc/anaconda/envs/tensorflow/bin/python"
(no matter whether I activate tensorflow in terminal)

It seems that the spyder and Jupyter run two different built-in Python (version of both are 2.7.11), one from anaconda, and the other from tensorflow. Now I want Jupyter to run with the anaconda python. Could anyone please instruct me how to do this?

Any hint will be appreciated. Thank you very much!

Question

Most helpful comment

They're both running in Anaconda Python, but in different environments. You may have installed an IPython kernelspec with that environment active, or you may have launched Jupyter inside that environment.

Either way, you should be able to make it use the root environment (the same one Spyder is using) by installing the kernelspec without activating any environment. The command for that is:

python -m ipykernel install --user

All 5 comments

They're both running in Anaconda Python, but in different environments. You may have installed an IPython kernelspec with that environment active, or you may have launched Jupyter inside that environment.

Either way, you should be able to make it use the root environment (the same one Spyder is using) by installing the kernelspec without activating any environment. The command for that is:

python -m ipykernel install --user

Also no need to post twice, we saw the comment on the other thread it can just take timefor us to respond.

Problems solved! Thank you very much!

Problems solved! Thank you very much!

Thanks, closing.

They're both running in Anaconda Python, but in different environments. You may have installed an IPython kernelspec with that environment active, or you may have launched Jupyter inside that environment.

Either way, you should be able to make it use the root environment (the same one Spyder is using) by installing the kernelspec without activating any environment. The command for that is:

python -m ipykernel install --user

This actually broke down my entire Jupyter Notebook... Now I find it very difficult to undo the damange

Was this page helpful?
0 / 5 - 0 ratings