I opened a jupyter notebook from an anaconda enviiroment but the kernel uses a default version of python instead of the python defined in this enviroment (That has all pthe packages i installed).
How can I change it?
(myEnv) okoub@my-mac:~/Desktop$jupyter notebook
[I 13:35:46.644 NotebookApp] The port 8888 is already in use, trying another port.
[I 13:35:46.646 NotebookApp] The port 8889 is already in use, trying another port.
[I 13:35:46.675 NotebookApp] JupyterLab alpha preview extension loaded from /Users/okoub/anaconda3/lib/python3.6/site-packages/jupyterlab
I am using MAC.
After installing jupyter in the enviroment:
source activate myEnv
conda install jupyter
jupyter notebook
I get the error:
File "/Users/okoub/anaconda3/envs/myEnv/lib/python3.5/site-packages/prompt_toolkit/completion/base.py", line 4, in <module>
from prompt_toolkit.eventloop import generator_to_async_generator, AsyncGeneratorItem
ImportError: cannot import name 'generator_to_async_generator'
[W 14:54:56.587 NotebookApp] KernelRestarter: restart failed
[W 14:54:56.587 NotebookApp] Kernel dcc36e3e-9352-402f-a513-ca1dca30e460 died, removing from map.
[W 14:55:41.612 NotebookApp] Timeout waiting for kernel_info reply from dcc36e3e-9352-402f-a513-ca1dca30e460
[E 14:55:41.616 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: dcc36e3e-9352-402f-a513-ca1dca30e460)
[I 14:56:41.524 NotebookApp] Saving file at /my_notebook.ipynb
To change the kernel version in Jupyter Python Notebooks follow the steps below : Open the Python Notebook and click on " Kernel " from the menu bar located on top of the python notebook. Click on " Change kernel " from the drop down box that appears and chose the version that is required.
With a new Jupyter notebook open, you can click Kernel > Change kernel > and select the virtual environment you need.
By default, that will be the version of python that is used for any new environment you create. However, you can specify any version of python installed on your computer to use inside a new environment with the -p flag : $ virtualenv -p python3. 2 my_env Running virtualenv with interpreter /usr/local/bin/python3.
Run a conda install nb_conda_kernels
, then restart jupyter
. There should now be an additional option in the top right corner to choose which conda env
the notebook should use for code execution. This is the most convenient solution IMO since you can have multiple notebooks in the same project that operate with their own respective environments rather than having to source activate
all the time.
Read more here: 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