pip3 install PyQt5 --user 失败

2022-01-12 00:00:00 python pip pyqt pyqt5 python-sip

问题描述

尝试通过 pip3 安装 PyQt5 时出现错误.自动消息要我添加更多细节,但我没有.所有细节都在代码中.

Errors are present when trying to install PyQt5 via pip3. The automated message wants me to add more detail, but I don't have any. All the detail is in the code.

➜  ~ pip3 install PyQt5 --user 
Collecting PyQt5
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.VerifiedHTTPSConnection object at 0x7f2c97cfeb50>: Failed to establish a new connection: [Er
rno -2] Name or service not known')': /simple/pyqt5/
  Using cached https://files.pythonhosted.org/packages/3a/fb/eb51731f2dc7c22d8e1a63ba88fb702727b324c6352183a32f27f73b8116/PyQt5-5.14.1.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    Complete output from command /usr/bin/python3 /usr/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp3yjy_ooq:
    Traceback (most recent call last):
      File "/usr/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 64, in prepare_metadata_for_build_wheel
        hook = backend.prepare_metadata_for_build_wheel
    AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "/usr/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
        main()
      File "/usr/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/usr/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 67, in prepare_metadata_for_build_wheel
        config_settings)
      File "/usr/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 95, in _get_wheel_metadata_from_wheel
        whl_basename = backend.build_wheel(metadata_directory, config_settings)
      File "/tmp/pip-build-env-1ms8fm3e/overlay/lib64/python3.7/site-packages/sipbuild/api.py", line 51, in build_wheel
        project = AbstractProject.bootstrap('pep517')
      File "/tmp/pip-build-env-1ms8fm3e/overlay/lib64/python3.7/site-packages/sipbuild/abstract_project.py", line 82, in bootstrap
        project.setup(pyproject, tool, tool_description)
      File "/tmp/pip-build-env-1ms8fm3e/overlay/lib64/python3.7/site-packages/sipbuild/project.py", line 387, in setup
        self.apply_user_defaults(tool)
      File "project.py", line 62, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-1ms8fm3e/overlay/lib/python3.7/site-packages/pyqtbuild/project.py", line 86, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-1ms8fm3e/overlay/lib64/python3.7/site-packages/sipbuild/project.py", line 202, in apply_user_defaults
        self.builder.apply_user_defaults(tool)
      File "/tmp/pip-build-env-1ms8fm3e/overlay/lib/python3.7/site-packages/pyqtbuild/builder.py", line 68, in apply_user_defaults
        "specify a working qmake or add it to PATH")
    sipbuild.pyproject.PyProjectOptionException

    ----------------------------------------
Command "/usr/bin/python3 /usr/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py prepare_metadata_for_build_wheel /tmp/tmp3yjy_ooq" failed with error code 1 in /tmp/pip-install-6w4gkbyk/PyQt5

尝试直接安装Qt,以获取QMake的路径,但无济于事.

Tried installing Qt directly, in order to get QMake in path, but to no avail.

➜  ~ qmake --version
QMake version 2.01a
Using Qt version 4.8.7 in /usr/lib64
➜  ~ 

操作系统信息(Fedora 30)

OS information (Fedora 30)

 5.2.11-200.fc30.x86_64 #1 SMP Thu Aug 29 12:43:20 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

更多版本

➜  ~ pip3 --version
pip 19.0.3 from /usr/lib/python3.7/site-packages/pip (python 3.7)
➜  ~ python3 --version
Python 3.7.5
➜  ~ 


解决方案

我在安装 tensorflow 时遇到了同样的错误.升级setuptools"和pip"到最新的次要版本对我有用.

I had the same error installing tensorflow. Upgrading "setuptools" and "pip" to the latest minor version worked for me.

相关文章