Can't import WMI Python module

2019-07-26 00:43发布

I'm new to python. I'm working in windows environment. mostly win7. My machine is win7 32bit also. I downloaded the wmi module and used the .exe to install it. when I try and 'import wmi', i get an error:

    Traceback (most recent call last):
      File "<pyshell#5>", line 1, in <module>
        import wmi
      File "C:\Python33\lib\wmi.py", line 88, in <module>
        from win32com.client import GetObject, Dispatch
    ImportError: No module named 'win32com'

How can I solve this? Does win7 compliant with this module?

Regards

3条回答
何必那么认真
2楼-- · 2019-07-26 01:18

download WMI-1.4.9.win32.exe from https://pypi.python.org/pypi/WMI/ and it will resolve your problem

查看更多
霸刀☆藐视天下
3楼-- · 2019-07-26 01:27

What worked for me is: i downloaded the source named: WMI-1.4.9.zip from https://pypi.python.org/pypi/WMI/ Extracted all files from that zip file and saved it in a folder named: WMI-1.4.9 and then copied that folder to C:\Python27\Lib\site-packages. After that I navigated to that folder C:\Python27\Lib\site-packages\WMI-1.4.9 and did a shift + right click -> Open Command line here and ran: python setup.py install

That's it, after that it worked for me like charm. No issues.

p.s - While installing exe I had some weird Access Denied errors, I tried by running the exe as Administrator even then I could get through it. Hence that didn't at all work for me.

Also I had pywin32 installed from here: http://sourceforge.net/projects/pywin32/files/ (select the correct file - 'bittedness' and python version wise)

查看更多
迷人小祖宗
4楼-- · 2019-07-26 01:31

Instead you can also install win32com which would resolve the issue. To install win32com use:

pip install pypiwin32

查看更多
登录 后发表回答