安装 win32gui python 模块
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20113456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing win32gui python module
提问by user3014911
I am trying to get the name of the window currently in focus by running this code...
我正在尝试通过运行此代码来获取当前处于焦点的窗口的名称...
import win32gui
name = win32gui.GetForegroundWindow()
However, I keep getting
然而,我不断得到
Traceback (most recent call last):
File "D:\Program_1\test.py", line 1, in <module>
import win32gui
ImportError: No module named win32gui
I installed pywin32 from here http://sourceforge.net/projects/pywin32/?source=navbar. What is the mistake I am making; guessing it is something very basic. Thanks in advance.
我从这里安装了 pywin32 http://sourceforge.net/projects/pywin32/?source=navbar。我犯了什么错误;猜测这是非常基本的事情。提前致谢。
EDIT: Found the solution. I was installing a 32bit pywin32 on a 64bit Windows 7 because the 64bit version gave me an error, it could not find the Python registry. I found a solution here Python version 2.6 required, which was not found in the registry. Reinstalling Python and installing it just for myself resulted in no errors given by pywin32 64bit installation.
编辑:找到解决方案。我在 64 位 Windows 7 上安装了 32 位 pywin32,因为 64 位版本给了我一个错误,它找不到 Python 注册表。我在这里找到了需要 Python version 2.6的解决方案,但在注册表中找不到。重新安装 Python 并仅为自己安装它导致 pywin32 64 位安装没有出现错误。
回答by iChux
See this link: http://www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32. It may be of help to you.
请参阅此链接:http: //www.lfd.uci.edu/~gohlke/pythonlibs/#pywin32。它可能对你有帮助。
EDIT: (easy version)
编辑:(简易版)
Step 1: Download the pywin32....whl
Step 2: pip install pywin32....whl
Step 3: C:\python32\python.exe Scripts\pywin32_postinstall.py -install
Step 4: python
>>> import win32gui


