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
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
解决方案
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.