python报错 ModuleNotFoundError: No module named 'win32api' //import win32api ImportError: DLL load fai

大概的错误就是:
import win32api
ImportError: DLL load failed: 找不到指定的程序。

具体点:

[I 20:32:41.034 NotebookApp] Serving notebooks from local directory: C:\Users\17520
[I 20:32:41.034 NotebookApp] The Jupyter Notebook is running at:
[I 20:32:41.034 NotebookApp] http://localhost:8888/?token=d07ff3094e633ca9acadf5c394daef127663251a7ec9ae0e
[I 20:32:41.034 NotebookApp] or http://127.0.0.1:8888/?token=d07ff3094e633ca9acadf5c394daef127663251a7ec9ae0e
[I 20:32:41.035 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:32:41.450 NotebookApp] 

To access the notebook, open this file in a browser:
file:///C:/Users/17520/AppData/Roaming/jupyter/runtime/nbserver-14724-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=d07ff3094e633ca9acadf5c394daef127663251a7ec9ae0e
or http://127.0.0.1:8888/?token=d07ff3094e633ca9acadf5c394daef127663251a7ec9ae0e
[I 20:32:47.705 NotebookApp] Creating new notebook in 
[E 20:32:49.379 NotebookApp] Uncaught exception POST /api/sessions (::1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='POST', uri='/api/sessions', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1699, in _execute
result = await result
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\handlers.py", line 72, in post
type=mtype))
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 88, in create_session
kernel_id = yield self.start_kernel_for_session(session_id, path, name, type, kernel_name)
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 742, in run
yielded = self.gen.throw(*exc_info) # type: ignore
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\sessions\sessionmanager.py", line 101, in start_kernel_for_session
self.kernel_manager.start_kernel(path=kernel_path, kernel_name=kernel_name)
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 735, in run
value = future.result()
File "C:\Users\17520\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 209, in wrapper
yielded = next(result)
File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 168, in start_kernel
super(MappingKernelManager, self).start_kernel(**kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\multikernelmanager.py", line 110, in start_kernel
km.start_kernel(**kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 476, in write_connection_file
kernel_name=self.kernel_name
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "C:\ProgramData\Anaconda3\lib\contextlib.py", line 112, in __enter__
return next(self.gen)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_core\paths.py", line 424, in secure_write
win32_restrict_file_to_user(fname)
File "C:\ProgramData\Anaconda3\lib\site-packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed: 找不到指定的程序。
[W 20:32:49.399 NotebookApp] Unhandled error
[E 20:32:49.399 NotebookApp] {
     
"Host": "localhost:8888",
"Connection": "keep-alive",
"Content-Length": "93",
"Accept": "application/json, text/javascript, */*; q=0.01",
"Origin": "http://localhost:8888",
"X-Requested-With": "XMLHttpRequest",
"X-Xsrftoken": "2|ba1dd496|03390c32c348206332d173df8cdfa02f|1575048795",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",
"Content-Type": "application/json",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "cors",
"Referer": "http://localhost:8888/notebooks/Untitled37.ipynb?kernel_name=python3",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cookie": "username-localhost-8890=\"2|1:0|10:1575048795|23:username-localhost-8890|44:OGE1ZWNkOTYwZWM1NDg5Y2FiYWEzNDY3ZTg2YTUyMjM=|91b08c9deaf644e6bbe923903ae8419ca0d445ed222b51d5b9deeadaadf92ef3\"; _xsrf=2|ba1dd496|03390c32c348206332d173df8cdfa02f|1575048795; username-localhost-8888=\"2|1:0|10:1575549164|23:username-localhost-8888|44:MTA2NWU1ZWRmOGE2NDBlMjhjNGM2MTFhOTRhMDI5M2Q=|15a95f4ecd5f4d4c366974e10b4e0c7ebdc0dfd1c8ba507de571ed04e5c04f2d\""
}
[E 20:32:49.399 NotebookApp] 500 POST /api/sessions (::1) 256.73ms referer=http://localhost:8888/notebooks/Untitled37.ipynb?kernel_name=python3
[W 20:32:49.414 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20191205203240 (::1) 12.98ms referer=http://localhost:8888/notebooks/Untitled37.ipynb?kernel_name=python3

解决方法:

安装 win32api 下面带有连接,直接安装后运行即可(注意你的python版本,如果不对的话就退一个版本安装,比如你安装的3.8的python,但是 安装下面连接的win32api后没有反应 ,就哟啊退回一个版本 比如3.7,安装3.7的win32api)

https://github.com/mhammond/pywin32/releases
安装好后运行:
在这里插入图片描述
双击:

python报错 ModuleNotFoundError: No module named 'win32api' //import win32api ImportError: DLL load fai_第1张图片
下一步

python报错 ModuleNotFoundError: No module named 'win32api' //import win32api ImportError: DLL load fai_第2张图片
下一步,然后安装即可
python报错 ModuleNotFoundError: No module named 'win32api' //import win32api ImportError: DLL load fai_第3张图片
如果版本不对,可能就会有如下上情况 , 直接换一个版本就好了。

你可能感兴趣的:(笔记,错误,python)