I am trying to import pythoncom, but it gives me this error: Traceback (most recent call last):

File "F:/Documents and Settings/Emery/Desktop/Python 27/Try", line 2, in

import pythoncom

File "F:\Python27\lib\site-packages\pythoncom.py", line 2, in

import pywintypes

ImportError: No module named pywintypes

I reinstalled Python win32, but it still doesn't fix it. Any help? Also, I am trying to access the pythoncom.PumpMessages() method, an alternative would be nice as well.

解决方案

If you are using an IDE like I am (PyCharm), you should go the where the Python is installed e.g C:\Users\***\AppData\Local\Programs\Python\Python37\Lib\site-packages

In this folder check for the folder name pywin32. Copy that folder and paste it to C:\Users\***\PycharmProjects\project\venv\Lib\site-packages. After that restart your IDE, then it will import the pywin32 as it did in my case. I hope it helps.

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐