Python 导入错误:没有名为 win32api 的模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21343774/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: no module named win32api
提问by akshay
I am using Python 2.7and I want to use pywin32-214on Windows 7. I installed pywin32-214by using the msiinstaller. But when I import win32apiin my Python script, it throws the error:
我正在使用Python 2.7并且我想pywin32-214在Windows 7. 我pywin32-214使用msi安装程序安装。但是当我win32api在我的 Python 脚本中导入时,它会抛出错误:
no module named win32api.
What should I do? Can I use pywin32 apifor Windows 7?
我该怎么办?我可以pywin32 api用于Windows 7吗?
回答by Erica Kane
I had an identical problem, which I solved by restarting my Python editor and shell. I had installed pywin32but the new modules were not picked up until the restarts.
我有一个相同的问题,我通过重新启动 Python 编辑器和 shell 解决了这个问题。我已经安装,pywin32但新模块直到重新启动才被接收。
If you've already done that, do a search in your Python installation for win32apiand you should find win32api.pydunder ${PYTHON_HOME}\Lib\site-packages\win32.
如果您已经这样做了,请在您的 Python 安装中搜索win32api,您应该win32api.pyd在${PYTHON_HOME}\Lib\site-packages\win32.
回答by Ciwidey Developer
This is resolve my case as found on Where to find the win32api module for Python?
这是解决我的情况,如在 何处找到 Python 的 win32api 模块?
pip install pypiwin32
回答by neves
I didn't find the package of the most voted answer in my Python 3 dist.
我没有在我的 Python 3 dist 中找到投票最多的答案包。
I had the same problem and solved it installing the module pywin32:
我遇到了同样的问题并通过安装模块 pywin32 解决了这个问题:
In a normal python:
在普通的蟒蛇中:
pip install pywin32
In anaconda:
在蟒蛇中:
conda install pywin32
My python installation (Intel? Distribution for Python) had some kind of dependency problem and was giving this error. After installing this module it stopped appearing.
我的 Python 安装(英特尔?Python 发行版)存在某种依赖性问题,并出现此错误。安装此模块后,它停止出现。
回答by Juano
According to pywin32 githubyou must run
根据pywin32 github你必须运行
pip install pywin32
and after that, you must run
在那之后,你必须运行
python Scripts/pywin32_postinstall.py -install
I know I'm reviving an old thread, but I just had this problem and this was the only way to solve it.
我知道我正在恢复一个旧线程,但我刚刚遇到了这个问题,这是解决它的唯一方法。
回答by sameer_nubia
After installing pywin32
安装pywin32后
Steps to correctly install your module (pywin32)
正确安装模块的步骤 (pywin32)
First search where is your python pip is present
1a. For Example in my case location of pip - C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts
Then open your command prompt and change directory to your pip folder location.
cd C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts>pip install pypiwin32
首先搜索您的python pip在哪里
1a. 例如,在我的 pip 位置 - C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts
然后打开您的命令提示符并将目录更改为您的 pip 文件夹位置。
cd C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts C:\Users\username\AppData\Local\Programs\Python\Python36-32\Scripts>pip install pypiwin32
Restart your IDE
重启你的 IDE
All done now you can use the module .
现在一切都完成了,您可以使用该模块了。

