友善Nona Pi开发板ubuntu22.04系统用Python3.8.17的pip安装PyQt5.15.2时报错“Q_PID”这个宏未定义的一种解决办法

安装命令:

pip install PyQt5==5.15.2 --config-settings --confirm-license= --verbose -i https://mirrors.aliyun.com/pypi/simple/

遇到出错:

如图:
友善Nona Pi开发板ubuntu22.04系统用Python3.8.17的pip安装PyQt5.15.2时报错“Q_PID”这个宏未定义的一种解决办法_第1张图片

分析具体错误内容:
 

  These bindings will be built: Qt, QtCore, QtNetwork, QtGui, QtWidgets, QtDBus, QtSql, QtXml, _QOpenGLFunctions_ES2, pylupdate, pyrcc.
  Generating the Qt bindings...
  _in_process.py: /tmp/pip-install-asecfkf9/pyqt5_19c1396a09f04101828420ed5f54c179/sip/QtCore/qprocess.sip: line 99: column 5: 'Q_PID' is undefined
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> See above for output.
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: /home/pi/anaconda3/envs/py38qt5/bin/python /home/pi/anaconda3/envs/py38qt5/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py prepare_metadata_for_build_wheel /tmp/tmpvs7_f0g7
  cwd: /tmp/pip-install-asecfkf9/pyqt5_19c1396a09f04101828420ed5f54c179
  Preparing metadata (pyproject.toml) ... error
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

友善Nona Pi开发板ubuntu22.04系统用Python3.8.17的pip安装PyQt5.15.2时报错“Q_PID”这个宏未定义的一种解决办法_第2张图片

解决办法:打开/sip/QtCore/qprocess.sip这个文件,除过30行,删除23—32之间的行:
友善Nona Pi开发板ubuntu22.04系统用Python3.8.17的pip安装PyQt5.15.2时报错“Q_PID”这个宏未定义的一种解决办法_第3张图片

我的解决办法是:
先用WinScp进入开发板的 /tmp目录,然后执行安装命令,立即刷新此目录, 找到最新的一个以“pip-install-*”开头的子目录,然后依次进入/pyqt5_****/sip/QtCore/子目录,找到qprocess.sip,把这个文件拖到本地,修改好后,再拖到开发板中覆盖。
如果仍然提示错误,说明你手太慢。重来一遍,手速够快的话就不报错了。

经过漫长的等待,发现PyQt5.15.2安装成功了。
 

你可能感兴趣的:(Python,PyQt5,python)