我尝试使用 pip 安装 win32gui,但出现此错误。我正在使用 python 3.8.5,我也有最新版本的 pip

Posted

技术标签:

【中文标题】我尝试使用 pip 安装 win32gui,但出现此错误。我正在使用 python 3.8.5,我也有最新版本的 pip【英文标题】:I tried installing win32gui using pip but I'm getting this error. I am using python 3.8.5, I have latest version of pip too 【发布时间】:2020-09-06 06:47:38 【问题描述】:
C:\Users\Viraj Sharma>pip install win32gui
Collecting win32gui
  Using cached win32gui-221.5.tar.gz (605 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  ERROR: Command errored out with exit status 1:
   command: 'c:\users\viraj sharma\appdata\local\programs\python\python38\python.exe' 'c:\users\viraj sharma\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\VIRAJS~1\AppData\Local\Temp\tmpjn8lvta1'
       cwd: C:\Users\Viraj Sharma\AppData\Local\Temp\pip-install-gcbm1r68\win32gui
  Complete output (20 lines):
  Traceback (most recent call last):
    File "c:\users\viraj sharma\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 280, in <module>
      main()
    File "c:\users\viraj sharma\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 263, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "c:\users\viraj sharma\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py", line 114, in get_requires_for_build_wheel
      return hook(config_settings)
    File "C:\Users\Viraj Sharma\AppData\Local\Temp\pip-build-env-9wmd0fza\overlay\Lib\site-packages\setuptools\build_meta.py", line 149, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "C:\Users\Viraj Sharma\AppData\Local\Temp\pip-build-env-9wmd0fza\overlay\Lib\site-packages\setuptools\build_meta.py", line 130, in _get_build_requires
      self.run_setup()
    File "C:\Users\Viraj Sharma\AppData\Local\Temp\pip-build-env-9wmd0fza\overlay\Lib\site-packages\setuptools\build_meta.py", line 253, in run_setup
      super(_BuildMetaLegacyBackend,
    File "C:\Users\Viraj Sharma\AppData\Local\Temp\pip-build-env-9wmd0fza\overlay\Lib\site-packages\setuptools\build_meta.py", line 145, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 27, in <module>
      from win32.distutils.gui import win32gui_build_ext
    File "C:\Users\Viraj Sharma\AppData\Local\Temp\pip-install-gcbm1r68\win32gui\win32\distutils\gui.py", line 6, in <module>
      from .command import win32_build_ext
  ModuleNotFoundError: No module named 'win32.distutils.command'
  ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\viraj sharma\appdata\local\programs\python\python38\python.exe' 'c:\users\viraj sharma\appdata\local\programs\python\python38\lib\site-packages\pip\_vendor\pep517\_in_process.py' get_requires_for_build_wheel 'C:\Users\VIRAJS~1\AppData\Local\Temp\tmpjn8lvta1' Check the logs for full command output.

【问题讨论】:

这能回答你的问题吗? ImportError: No module named win32com.client 【参考方案1】:

Python 3.7 或 3.8 与 win32gui 不兼容。

2019年发布3.8,2017年8月发布最新版win32gui。

我建议使用 python 3.6 或更低版本才能正常工作。

但是,还有另一种选择,通过安装 (pip install pywin32) 将安装 win32gui 以及用于与 windows 交互的模块。

【讨论】:

【参考方案2】:

你可以使用下面的命令来安装win32gui。

pip install pywin32

【讨论】:

以上是关于我尝试使用 pip 安装 win32gui,但出现此错误。我正在使用 python 3.8.5,我也有最新版本的 pip的主要内容,如果未能解决你的问题,请参考以下文章

win32gui安装通过pip失败

python import win32gui报错

无法加载 pywin32 库 win32gui

安装win32gui python模块[重复]

如何通过 pip 为 Python 3.5 安装 Pygame?

使用 win32gui 使窗口居中