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

安装命令:

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

遇到出错:

如图:

分析具体错误内容:

bash 复制代码
  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.

解决办法:打开/sip/QtCore/qprocess.sip这个文件,除过30行,删除23---32之间的行:

我的解决办法是:

先用WinScp进入开发板的 /tmp目录,然后执行安装命令,立即刷新此目录, 找到最新的一个以"pip-install-*"开头的子目录,然后依次进入/pyqt5_****/sip/QtCore/子目录,找到qprocess.sip,把这个文件拖到本地,修改好后,再拖到开发板中覆盖。

如果仍然提示错误,说明你手太慢。重来一遍,手速够快的话就不报错了。

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

相关推荐
写代码的【黑咖啡】7 分钟前
Python 中的 Requests 库:轻松进行 HTTP 请求
开发语言·python·http
栗子叶7 分钟前
Spring 中 Servlet 容器和 Python FastAPI 对比
python·spring·servlet·fastapi
杨杨杨大侠13 分钟前
DeepAgents 框架深度解析:从理论到实践的智能代理架构
后端·python·llm
袁袁袁袁满21 分钟前
Python读取doc文件打印内容
开发语言·python·python读取doc文件
m0_7482523836 分钟前
Ruby 模块(Module)的基本概念
开发语言·python·ruby
子午44 分钟前
【2026原创】水稻植物病害识别系统~Python+深度学习+人工智能+resnet50算法+TensorFlow+图像识别
人工智能·python·深度学习
深蓝电商API1 小时前
Scrapy ImagesPipeline和FilesPipeline自定义使用
爬虫·python·scrapy
木卫二号Coding1 小时前
Python-文件拷贝+文件重命名+shutil+记录
开发语言·python
爬山算法1 小时前
Hibernate(44)Hibernate中的fetch join是什么?
前端·python·hibernate
一代明君Kevin学长1 小时前
记录一个上手即用的Spring全局返回值&异常处理框架
java·网络·python·spring