一、jupyter notebook添加虚拟环境
1. 打开cmd,activate到需要添加到jupyter notebook的虚拟环境;
activate gymlab
2. 在当前环境中安装好ipykernel;
conda install ipykernel
3. 添加环境到jupyter notebook;
python -m ipykernel install --name gymlab
重启jupyter notebook就可以看到新增的环境。
但是在切换环境时,出现了“ImportError: DLL load failed while importing _device: 找不到指定的模块”的报错。
原因:pyzmq的版本不匹配导致。因为pyzmq版本过高,pyzmq就是一个类似于框架一样的东西,可以让编程更加简单、简洁和性能更高,当版本太高时,就会与Jupyter Notebook出现不兼容的情况,从而导致错误。
二、切换内核时出现ImportError: DLL load failed while importing _device: 找不到指定的模块解决方案
具体解决办法为:在需要添加到jupyter notebook的环境下,降低pyzmq版本
pip install pyzmq==23.0.0
重新运行,即可解决。