import wmi
c = wmi.WMI()
for s in c.Win32_Service (StartMode="Auto", State="Stopped"):
if raw_input ("Restart %s? " % s.Caption).upper() == "Y":
s.StartService()
내가받은 코드를 오류
Traceback (most recent call last):
File ".\see_wmi.py", line 1, in <module>
import wmi
ImportError: No module named wmi
를 실행하려고하면 여기 파이썬
http://timgolden.me.uk/python/wmi/index.html
을 WMI를 다운로드 방향을 따라 WMI 이름이 없습니다
편집 :
내가 파이썬 2.7.6를 사용하고 63,210EDIT2 :
내가 64 비트 Windows 2008 R2를 실행하고, 나는 https://pypi.python.org/pypi/WMI/에서 WMI-1.4.9.zip (MD5)를 다운로드했습니다. 내용을 추출하여 D : \ Python \ Tools \ Scripts에 저장했습니다. 나는
python setup.py.install
내가 D 추가 실행 : % 경로 %에 스크립트 \ \ 파이썬 \ 도구, 내가 코드를 실행할 때
import wmi
c = wmi.WMI()
for s in c.Win32_Service (StartMode="Auto", State="Stopped"):
if raw_input ("Restart %s? " % s.Caption).upper() == "Y":
s.StartService()
나는 오류를
Traceback (most recent call last):
File ".\see_wmi.py", line 1, in <module>
import wmi
File "D:\Python\lib\site-packages\wmi.py", line 88, in <module>
from win32com.client import GetObject, Dispatch
ImportError: No module named win32com.client
EDIT3를 얻을 :
는 지금 파이썬 2.7.6이 설치가 D입니다 :
01,235 \ Python27 16,나는 D 드라이브에 WMI-1.4.9.zip을 추출하고 다음
PS D:\WMI-1.4.9> python .\setup.py install
을 실행 그리고 출력은
running install
running build
running build_py
creating build
creating build\lib
copying wmi.py -> build\lib
running build_scripts
creating build\scripts-2.7
copying wmitest.py -> build\scripts-2.7
copying wmiweb.py -> build\scripts-2.7
copying wmitest.cmd -> build\scripts-2.7
copying wmitest.master.ini -> build\scripts-2.7
running install_lib
copying build\lib\wmi.py -> D:\Python27\Lib\site-packages
byte-compiling D:\Python27\Lib\site-packages\wmi.py to wmi.pyc
running install_scripts
creating D:\Python27\Scripts
copying build\scripts-2.7\wmitest.cmd -> D:\Python27\Scripts
copying build\scripts-2.7\wmitest.master.ini -> D:\Python27\Scripts
copying build\scripts-2.7\wmitest.py -> D:\Python27\Scripts
copying build\scripts-2.7\wmiweb.py -> D:\Python27\Scripts
running install_data
warning: install_data: setup script did not provide a directory for 'readme.txt' -- installing right in 'D:\Python27'
running install_egg_info
Writing D:\Python27\Lib\site-packages\WMI-1.4.9-py2.7.egg-info
하지만 난 내 원래의 코드를 실행할 때, 저도 같은 오류가
PS D:\SymantecDLP\Protect> python .\see_wmi.py
Traceback (most recent call last):
File ".\see_wmi.py", line 1, in <module>
import wmi
File "D:\Python27\lib\site-packages\wmi.py", line 88, in <module>
from win32com.client import GetObject, Dispatch
ImportError: No module named win32com.client
EDIT4 :
그리고 난에 다음을 포함 당신이 파이썬 2를 사용하는 경우
, 당신은
python setup.py install
파이썬 2 작동
있지만를 사용해야합니다 내가 찾은 %의 PATH %
D:\Python27;D:\Python27\Lib\;D:\Python27\Lib\site-packages
https://pypi.python.org/pypi/WMI/ 여기에서 wmi를 다운로드 했습니까? –
@BenjiSparks - 예 거기에서 다운로드했습니다. – Glowie