????为了防止python环境变乱,于是新建子环境进行不同项目操作。最近想使用jupyter切换环境进行操作。遇到了下列问题:
1. 安装插件,使jupyter可以切换环境
2. ImportError: DLL load failed: 找不到指定的模块。
3. ImportError: DLL load failed: 找不到指定的程序。
一、安装插件
????想要在jupyter下切换环境运行,需要安装以下插件:
#有两个环境,tf1,和tf2,激活
conda activate tf1
#安装ipython kernel
pip install ipykernel
#链接当前环境到jupyter
python -m ipykernel install --user --name=tf1
#然后是另一个环境,做同样操作
conda activate tf2
pip install ipykernel
python -m ipykernel install --user --name=tf2
????Anaconda Prompt
中的切换界面:
????我新建的环境名称是:caffe-fzp
,安装好插件后,即可在jupyter的Homepage
中看见:
????点击新的环境caffe-fzp
即可进入子环境:
????But!运行过程中,。陆续出现了不少问题,下面是问题记录:
二、ImportError: DLL load failed: 找不到指定的模块。
????报错的提示如下:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 47, in <module>
from zmq.eventloop import ioloop
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\__init__.py", line 47, in <module>
from zmq import backend
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\select.py", line 27, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\ProgramData\Anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed: 找不到指定的模块。
- 问题原因:
????zmq
包是用于连接的,若出现问题,会导致连接不上服务器。我的问题是版本不匹配。 - 解决办法:
- 切换到子环境,再卸载旧版本
pip uninstall pyzmq
 ; ; ; ;从截图中即可看出,旧版本是17.1.2。
- 在子环境里,重新下载新版本
pip install pyzmq
 ; ; ; ;从截图中即可看出,安装的新版本是18.1.1。
Bingo!ImportError: DLL load failed: 找不到指定的模块。
问题到这里就解决啦。
 ; ; ; ;如果和我一样又出现了ImportError: DLL load failed: 找不到指定的程序。
问题,继续看下一点。
三、ImportError: DLL load failed: 找不到指定的程序
[I 10:41:35.455 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\ipykernel_launcher.py", line 16, in <module>
app.launch_new_instance()
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\traitlets\config\application.py", line 663, in launch_instance
app.initialize(argv)
File "<D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\decorator.py:decorator-gen-125>", line 2, in initialize
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\traitlets\config\application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\ipykernel\kernelapp.py", line 550, in initialize
self.write_connection_file()
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\ipykernel\kernelapp.py", line 227, in write_connection_file
iopub_port=self.iopub_port, control_port=self.control_port)
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\jupyter_core\paths.py", line 430, in secure_write
win32_restrict_file_to_user(fname)
File "D:\InstallSoftware\Anaconda\envs\caffe-fzp\lib\site-packages\jupyter_core\paths.py", line 361, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: 找不到指定的程序。
原文地址:https://www.cnblogs.com/somedayLi/p/12320878.html
时间: 2024-10-05 23:25:06