笔记本选择python开发_将我的jupyter笔记本设置为使用python版本的环境

博主在Mac上遇到一个问题,打开Jupyter Notebook时,它使用的是默认的Python版本而不是指定环境中安装的Python,导致无法使用已安装的包。解决方法是通过运行`conda install nb_conda_kernels`,然后重启Jupyter,这样就可以在顶部选择使用哪个conda环境来执行代码,方便管理不同项目中的多个笔记本。
摘要由CSDN通过智能技术生成

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值