Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
QLQLQL opened this issue Jun 30, 2016 · 5 comments

Comments

@QLQLQL
Copy link

QLQLQL commented Jun 30, 2016

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: ##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!

@takluyver
Copy link
Member

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

@Carreau
Copy link
Member

Carreau commented Jun 30, 2016

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

@QLQLQL
Copy link
Author

QLQLQL commented Jul 1, 2016

Problems solved! Thank you very much!

@Carreau
Copy link
Member

Carreau commented Jul 1, 2016

Problems solved! Thank you very much!

Thanks, closing.

@Carreau Carreau closed this as completed Jul 1, 2016
@Carreau Carreau added this to the no action milestone Jul 1, 2016
@mesutyang97
Copy link

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants