使用Python 3.5而非Python 3.7的Qt Designer

时间:2018-07-02 22:44:04

标签: python c++ python-3.x qt pyqt5

我正在使用通过PyQt5用python 3编写的Qt Designer自定义窗口小部件,我不得不使用一个需要更新的sip API的资源文件,但是为此,我必须更新我的python。

我使用的是ubuntu 16.04 LTS,所以我只是从python.org下载了python,就是这样,一切都顺利进行了,如果我在bash中使用“ python3”命令,那么我会成功安装python 3.7 python 3.7环境运行正常。

但是当我执行Qt Designer时,出现以下错误:

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安装中找不到它,也许该插件指向该文件夹。

有任何提示或帮助吗?

1 个答案:

答案 0 :(得分:0)

尝试将其插入文件顶部:

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

在python文件的顶部;可以解决吗?