I installed Anaconda (with Python 2.7), and installed Tensorflow in an environment called tensorflow
. I can import Tensorflow successfully in that environment.
The problem is that Jupyter Notebook does not recognize the new environment I just created. No matter I start Jupyter Notebook from the GUI Navigator or from the command line within the tensorflow
env, there is only one kernel in the menu called Python [Root]
, and Tensorflow cannot be imported. Of course, I clicked on that option multiple times, saved file, re-opened, but these did not help.
Strangely, I can see the two environments when I open the Conda
tab on the front page of Jupyter. But when I open the Files
tab, and try to new
a notebook, I still end up with only one kernel.
I looked at this question: Link Conda environment with Jupyter Notebook But there isn't such a directory as ~/Library/Jupyter/kernels
on my computer! This Jupyter directory only has one sub-directory called runtime
.
I am really confused. Are Conda environments supposed to become kernels automatically? (I followed https://ipython.readthedocs.io/en/stable/install/kernel_install.html to manually set up the kernels, but was told that ipykernel
was not found.)
The IPython kernel is the Python execution backend for Jupyter. The Jupyter Notebook and other frontends automatically ensure that the IPython kernel is available. However, if you want to use a kernel with a different version of Python, or in a virtualenv or conda environment, you'll need to install that manually.
I don't think the other answers are working any more, as conda stopped automatically setting environments up as jupyter kernels. You need to manually add kernels for each environment in the following way:
source activate myenv python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
As documented here:http://ipython.readthedocs.io/en/stable/install/kernel_install.html#kernels-for-different-environments Also see this issue.
Addendum: You should be able to install the nb_conda_kernels
package with conda install nb_conda_kernels
to add all environments automatically, see https://github.com/Anaconda-Platform/nb_conda_kernels
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With