打算安装pyqt5,然后pip install PyQt5

报错:

Command "g:\python3.7\python.exe g:\python3.7\lib\site-packages\pip install --ignore-installed --no-user --prefix C:\Users\用户\AppData\Local\Temp\pip-build-env-o2fimxzi\overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- "sip >=6.4, <7" "PyQt-builder >=1.9, <2"" failed with error code 2 in None

可以下载,但是安装不行。

然后发现是没安装sip,于是pip install sip

还是报错:

Command "g:\python3.7\python.exe g:\python3.7\lib\site-packages\pip\_vendor\pep517\_in_process.py prepare_metadata_for_build_wheel C:\Users\用户\AppData\Local\Temp\tmp8voqpa7g" failed with error code 1 in C:\Users\用户\AppData\Local\Temp\pip-install-_xhpmsom\sip

于是接着搜索,发现是没有wheel模块,接着pip install wheel

wheel安装成功!

继续pip install sip

报错:

 error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

  ----------------------------------------
  Failed building wheel for sip
  Running setup.py clean for sip
Failed to build sip
Could not build wheels for sip which use PEP 517 and cannot be installed directly

搜索发现是缺少Visual C++ 14.0。

按照Microsoft Visual C++ 14.0 is required解决方法 - 知乎 (zhihu.com)

的办法成功安装VC++

继续pip install sip

sip安装成功!

接着pip install PyQt5还是失败

报错中有:

AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'

然后Google,找到python - AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel' for PyQt5 5.15.0 - Stack Overflow

此时我默认安装的版本是PyQt5 5.15.6,这篇文章的哥们也是这个问题,下面有个回复解释了一下,然后给出了解决办法:安装指定版本

python -m pip install PyQt5==5.15.2

于是成功安装pyqt5! 

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐