Qt Designer使用Python 3.5而不是Python 3.7

Qt Designer using Python 3.5 instead of Python 3.7

本文关键字:Python Designer Qt 使用      更新时间:2023-10-16

我正在使用在python 3到PyQt5上编写的Qt Designer自定义小部件,我不得不使用一个需要更新的sip API的资源文件,但为了做到这一点,我必须更新我的python。

我在 ubuntu 16.04 LTS 上,所以我刚刚从 python.org 下载了 python,就是这样,一切都没有问题,我设法安装 python 3.7 没有问题,如果我在 bash 中使用"python3"命令,python 3.7 环境运行良好。

但是当我执行Qt设计器时,我收到以下错误:

Traceback (most recent call last):
File "/home/ron/Qt/5.11.0/gcc_64/plugins/designer/python/QRoundProgressBarplugin.py", line 3, in <module>
from PyQt5.QtGui import QIcon
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtGui.so: undefined symbol: PySlice_AdjustIndices
Traceback (most recent call last):
File "/home/ron/Qt/5.11.0/gcc_64/plugins/designer/python/analogclockplugin.py", line 26, in <module>
from PyQt5.QtGui import QIcon, QPixmap
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtGui.so: undefined symbol: PySlice_AdjustIndices
Traceback (most recent call last):
File "/home/ron/Qt/5.11.0/gcc_64/plugins/designer/python/counterplugin.py", line 3, in <module>
from PyQt5.QtGui import QIcon
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtGui.so: undefined symbol: PySlice_AdjustIndices
Traceback (most recent call last):
File "/home/ron/Qt/5.11.0/gcc_64/plugins/designer/python/ledplugin.py", line 3, in <module>
from PyQt5.QtGui import QIcon
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtGui.so: undefined symbol: PySlice_AdjustIndices
Traceback (most recent call last):
File "/home/ron/Qt/5.11.0/gcc_64/plugins/designer/python/manometerplugin.py", line 3, in <module>
from PyQt5.QtGui import QIcon
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtGui.so: undefined symbol: PySlice_AdjustIndices
Traceback (most recent call last):
File "/home/ron/Qt/5.11.0/gcc_64/plugins/designer/python/switchplugin.py", line 3, in <module>
from PyQt5.QtGui import QIcon
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtGui.so: undefined symbol: PySlice_AdjustIndices
Traceback (most recent call last):
File "/home/ron/Qt/5.11.0/gcc_64/plugins/designer/python/thermometerplugin.py", line 3, in <module>
from PyQt5.QtGui import QIcon
ImportError: /usr/local/lib/python3.5/dist-packages/PyQt5/QtGui.so: undefined symbol: PySlice_AdjustIndices

当然,正如你所看到的,Qt Designer使用的是python 3.5的lib,所以无法找到最新的PyQt5(5.11(上存在的符号PySlice_AdjustIndices,但是在/usr/local/lib上我有python3.5和python3.7文件夹,每个文件夹都有一个PyQt5版本,但我真的不知道Qt Designer如何指向该文件夹而不是python3.7文件夹, 知道怎么做吗?

而且,只是为了让它知道,很明显,当Qt Designer加载python自定义小部件时会出现问题,我真的不记得我从哪里得到我的 libpyqt5.so(C++小部件告诉设计师如何阅读python小部件(,但我在我最近的PyQt5安装中找不到它,也许那个插件指向该文件夹。

任何提示或帮助?

尝试在文件顶部插入以下内容:

import os,sys
sys.path.insert(1,'/usr/local/lib/python3.7/dist-packages')

在你的 Python 文件的顶部;可能是一个变通方法?