conda环境下jupyter notebook无法连接到内核的问题解决

利用anaconda安装python环境,使用jupyter notebook进行编译,在导入package时就出现一大堆的报错

报错信息:

 

报错中特别强调让我们查看官方文档,描述如下:

Activating environments is essential to making the software in the environments work well. Activation entails two primary functions: adding entries to PATH for the environment and running any activation scripts that the environment may contain. These activation scripts are how packages can set arbitrary environment variables that may be necessary for their operation. You can also use the config API to set environment variables.

When installing Anaconda, you have the option to “Add Anaconda to my PATH environment variable.” This is not recommended because the add to PATH option appends Anaconda to PATH. When the installer appends to PATH, it does not call the activation scripts.

On Windows, PATH is composed of two parts, the system PATH and the user PATH. The system PATH always comes first. When you install Anaconda for Just Me, we add it to the user PATH. When you install for All Users, we add it to the system PATH. In the former case, you can end up with system PATH values taking precedence over our entries. In the latter case, you do not. We do not recommend multi-user installs.

Activation prepends to PATH. This only takes effect when you have the environment active so it is local to a terminal session, not global.

To activate an environment: 
conda activate myenv

大致意思是,出现这种情况的原因是没有事先激活conda 环境,需要在命令行(powershell不行)中激活。

 myenv是自己定义的环境名称。

仍然需要注意的一点是,acivate操作只针对当前目录的文件夹。如果在其他的地方打开jupyter notebook,也是无效的。

因此,要打开一个ipynb文件的操作最好是:

1.打开命令行

2.使用cd命令切换在文件所在目录

3.输入conda activate myenv(自己的环境名字)激活环境

4.输入jupyter notebook

便可以成功打开并完美编译了!

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值