简体   繁体   中英

Can't import WMI Python module

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

https://pypi.python.org/pypi/WMI/下载WMI-1.4.9.win32.exe,它将解决您的问题

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.

ps - 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)

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

pip install pypiwin32

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM