pywinauto: 导入时遇到 "TypeError: LoadLibrary() argument 1 must be string, not unicode"
- 经查询, 看到了同样的问题, 在*上面,
pywinauto import error for python 2.7 - Stack Overflow
http://*.com/questions/41653306/pywinauto-import-error-for-python-2-7
- 按照帖子里的回答, 问题出在: python 2.7.13里的ctypes模块有了新的变化. 解决办法是
- 要么降级到python 2.7.12里
- 要么升级pywinauto到0.6.1以上.
- 我选择第二种方案.
upgrade pywinauto to 0.6.2 from 0.5
之后, 导入pywinauto, 成功了!
import pywinauto
# Generating comtypes.gen._944DE083_8FB8_45CF_BCB7_C477ACB2F897_0_1_0
# Generating comtypes.gen._00020430_0000_0000_C000_000000000046_0_2_0
# Generating comtypes.gen.stdole
# Generating comtypes.gen.UIAutomationClient
pywinauto.__version__
Out[3]: '0.6.2'
C:\Documents and Settings\Administrator>pip install --upgrade pywinauto
Collecting pywinauto
Downloading pywinauto-0.6.2-1.zip (505kB)
100% |████████████████████████████████| 512kB 435kB/s
Requirement already up-to-date: six in d:\anaconda2\lib\site-packages (from pywinauto)
Collecting comtypes (from pywinauto)
Downloading comtypes-1.1.3-2.zip (179kB)
100% |████████████████████████████████| 184kB 544kB/s
Building wheels for collected packages: pywinauto, comtypes
Running setup.py bdist_wheel for pywinauto ... done
Stored in directory: C:\Documents and Settings\Administrator\Local Settings\Application Data\pip\Cache\wheels\48\f2\cf\549b15f185bc4e9fedafda46cbb24aa0eeb8289cfa999bf378
Running setup.py bdist_wheel for comtypes ... done
Stored in directory: C:\Documents and Settings\Administrator\Local Settings\Application Data\pip\Cache\wheels\16\4a\80\7e3d966317021cdf84659f0661887daf4266d33062378c1fc1
Successfully built pywinauto comtypes
Installing collected packages: comtypes, pywinauto
Found existing installation: comtypes 1.1.2
DEPRECATION: Uninstalling a distutils installed project (comtypes) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling comtypes-1.1.2:
Successfully uninstalled comtypes-1.1.2
Found existing installation: pywinauto 0.5.4
Uninstalling pywinauto-0.5.4:
Successfully uninstalled pywinauto-0.5.4
Successfully installed comtypes-1.1.3 pywinauto-0.6.2