问题:ImportError:没有名为win32api的模块

我使用Python 2.7,我想使用pywin32-214Windows 7。我pywin32-214通过使用msi安装程序进行安装。但是,当我导入win32apiPython脚本时,它会引发错误:

no module named win32api. 

我该怎么办?我可以使用pywin32 apiWindows 7

I am using Python 2.7 and I want to use pywin32-214 on Windows 7. I installed pywin32-214 by using the msi installer. But when I import win32api in my Python script, it throws the error:

no module named win32api. 

What should I do? Can I use pywin32 api for Windows 7?


回答 0

这可以解决我的情况,如在 哪里可以找到Python的win32api模块?

pip install pypiwin32

This is resolve my case as found on Where to find the win32api module for Python?

pip install pypiwin32

回答 1

我遇到了一个相同的问题,通过重新启动Python编辑器和Shell解决了该问题。我已经安装了,pywin32但是直到重新启动后才拾取新模块。

如果您已经这样做了,请在Python安装中进行搜索,win32api然后win32api.pyd在下找到${PYTHON_HOME}\Lib\site-packages\win32

I had an identical problem, which I solved by restarting my Python editor and shell. I had installed pywin32 but the new modules were not picked up until the restarts.

If you’ve already done that, do a search in your Python installation for win32api and you should find win32api.pyd under ${PYTHON_HOME}\Lib\site-packages\win32.


回答 2

根据pywin32 github你必须运行

    pip install pywin32

然后,您必须运行

    python Scripts/pywin32_postinstall.py -install

我知道我正在恢复一个旧线程,但是我只是遇到了这个问题,这是解决它的唯一方法。

According to pywin32 github you must run

    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.


回答 3

在我的Python 3发行版中,我没有找到投票率最高的答案。

我有同样的问题,并解决了安装模块pywin32的问题:

在普通的python中:

pip install pywin32

在水蟒中:

conda install pywin32

我的python安装(用于Python的英特尔®分发)存在某种依赖性问题,并出现此错误。安装此模块后,它停止出现。

I didn’t find the package of the most voted answer in my Python 3 dist.

I had the same problem and solved it installing the module 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.


回答 4

安装pywin32之后

正确安装模块的步骤(pywin32)

  1. 第一次搜索您的python pip在哪里

    1a。例如在我的情况下pip的位置-C:\ Users \ username \ AppData \ Local \ Programs \ Python \ Python36-32 \ Scripts

  2. 然后打开命令提示符,并将目录更改为您的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

重新启动IDE

现在所有操作都可以使用该模块了。

After installing pywin32

Steps to correctly install your module (pywin32)

  1. 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

  2. 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
    

Restart your IDE

All done now you can use the module .


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。