友善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安装成功了。

相关推荐
敏编程2 小时前
一天一个Python库:jsonschema - JSON 数据验证利器
python
前端付豪2 小时前
LangChain记忆:通过Memory记住上次的对话细节
人工智能·python·langchain
databook3 小时前
ManimCE v0.20.1 发布:LaTeX 渲染修复与动画稳定性提升
python·动效
花酒锄作田15 小时前
使用 pkgutil 实现动态插件系统
python
前端付豪19 小时前
LangChain链 写一篇完美推文?用SequencialChain链接不同的组件
人工智能·python·langchain
曲幽20 小时前
FastAPI实战:打造本地文生图接口,ollama+diffusers让AI绘画更听话
python·fastapi·web·cors·diffusers·lcm·ollama·dreamshaper8·txt2img
老赵全栈实战20 小时前
Pydantic配置管理最佳实践(一)
python
阿尔的代码屋1 天前
[大模型实战 07] 基于 LlamaIndex ReAct 框架手搓全自动博客监控 Agent
人工智能·python
AI探索者2 天前
LangGraph StateGraph 实战:状态机聊天机器人构建指南
python
AI探索者2 天前
LangGraph 入门:构建带记忆功能的天气查询 Agent
python