python - Anaconda Jupyter Notebook Kernel error ImportError: DLL load failed while importing win32api: The specified procedure could not be found
问题描述
我之前在 Visual Studio 代码中运行过 python 3.8 和 jupyter notebook。安装 Anaconda 后,我无法再运行 jupyter notebook,并且出现内核错误。
Traceback (most recent call last):
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\tornado\web.py", line 1704, in _execute
result = await result
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 69, in post
model = yield maybe_future(
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 98, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 769, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 110, in start_kernel_for_session
kernel_id = yield maybe_future(
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\tornado\gen.py", line 762, in run
value = future.result()
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 176, in start_kernel
kernel_id = await maybe_future(self.pinned_superclass.start_kernel(self, **kwargs))
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\jupyter_client\multikernelmanager.py", line 186, in start_kernel
km.start_kernel(**kwargs)
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\jupyter_client\manager.py", line 337, in start_kernel
kernel_cmd, kw = self.pre_start_kernel(**kw)
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\jupyter_client\manager.py", line 286, in pre_start_kernel
self.write_connection_file()
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 466, in write_connection_file
self.connection_file, cfg = write_connection_file(self.connection_file,
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\jupyter_client\connect.py", line 136, in write_connection_file
with secure_write(fname) as f:
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\jupyter_core\paths.py", line 461, in secure_write
win32_restrict_file_to_user(fname)
File "C:\Users\*****\AppData\Roaming\Python\Python38\site-packages\jupyter_core\paths.py", line 387, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed while importing win32api: The specified procedure could not be found.
我已经尝试过conda install ipykernel --update-deps
,conda install pywin32
但问题仍然存在。我怎样才能解决这个问题?
解决方案
这个建议对我有用: pip uninstall pywin32 然后 conda 再次安装它: https://github.com/jupyter/notebook/issues/4980#issuecomment-663885620
如何使用 conda 中的 pip:打开 Anaconda。在主页下方的左侧窗格中选择环境。在您选择的位置右侧和“搜索环境”栏下方,您应该看到 base(root)。点击它。应该出现一个指向右侧的三角形,单击它并选择“打开终端”在此处使用常规 pip install 命令。
然后如何使用 anaconda 安装 pywin32:根据本网站https://anaconda.org/anaconda/pywin32以管理员身份从 anaconda 提示符运行 conda install :
conda install -c anaconda pywin32
推荐阅读
- html - 在模态对话框中实现下拉菜单:我无法设置动态显示的值
- javascript - 我从 RestAPI 得到一个 json 对象的列表,我想在节点红色仪表板中可视化该列表的第一个值
- ffmpeg - FFMPEG 在 concat 后降低帧速率,并增加视频持续时间
- heroku - 将 RedisDB 与 Express-Gateway 一起使用。如何从 .ENV 读取数据库凭据?
- jenkins - 如何根据不同的分支为多个环境设置 Jenkins 管道?
- excel - 是否有 excel VBA 代码可以在表已满时扩展或向表中添加行?
- node.js - 由于校验和不匹配,nvm install nodejs 失败
- single-sign-on - 如何使用 SAML2.0 for sso 从 DBEAVER 连接到 Snowflake
- c# - Xamarin.Forms:使用 Picker 时指定的错误类型转换无效
- html - 如何在表格的每一行中显示列名?