我在我的Xubuntu (旅行者)上安装了一个明显较旧的PyQt5版本。当我打印PYQT_VERSION_STR时,它会显示:'5.2.1'。我在这里下载了最新的PyQt5发布表单:http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.4/ --我配置了它,制作并安装了它,一切都按照计划进行。但是,如果我再次打印PYQT_VERSION_STR,它仍然输出'5.2.1'。
我如何告诉python3.4使用更新版本?
(新版本的重新安装不应该覆盖另一个版本吗?我不明白为什么它仍然显示5.2.1作为版本字符串。)
编辑#1:
sys.path:‘,’/home/user/..pythonbrew/lib‘,'/usr/lib/python3.4','/usr/lib/python3.4/plat-x86_64-linux-gnu','/usr/lib/python3.4/lib-dynload','/usr/local/lib/python3.4/dist-packages',/usr/lib/python3/dist-packages’
PyQt5.__file__ '/usr/lib/python3/dist-packages/PyQt5/init.py‘
因此,我的python似乎正在使用存储库中的版本,除非在make安装时它是在那里安装的。
编辑#2:
PYQT_VERSION_STR似乎返回了Qt (!)的版本。在制作和制作安装前的PyQt5配置找到了哪些。因此,实际问题似乎与我的Qt5版本有关,根据python configure of PyQt5的输出,它是5.2.1:
Querying qmake about your Qt installation...
Determining the details of your Qt installation...
This is the GPL version of PyQt 5.4 (licensed under the GNU General Public License) for Python 3.4.0 on linux.
Type 'L' to view the license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.
Do you accept the terms of the license? yes
Found the license file pyqt-gpl.sip.
Checking [...]
DBus v1 does not seem to be installed.
Qt v5.2.1 (Open Source) is being used.
The qmake executable is /usr/bin/qmake.
Qt is built as a shared library.
SIP 4.16.5 is being used.
The sip executable is /usr/bin/sip.
These PyQt5 modules will be built: QtCore, QtGui, QtNetwork, QtOpenGL,
QtPrintSupport, QtQml, QtQuick, QtSql, QtTest, QtWidgets, QtXml, QtDBus, _QOpenGLFunctions_2_0.
The PyQt5 Python package will be installed in /usr/lib/python3.4/site-packages.
PyQt5 is being built with generated docstrings.
PyQt5 is being built with 'protected' redefined as 'public'.
The Designer plugin will be installed in
/usr/lib/x86_64-linux-gnu/qt5/plugins/designer.
The qmlscene plugin will be installed in
/usr/lib/x86_64-linux-gnu/qt5/plugins/PyQt5.
The PyQt5 .sip files will be installed in /usr/share/sip/PyQt5.
pyuic5, pyrcc5 and pylupdate5 will be installed in /usr/bin.
The interpreter used by pyuic5 is /usr/bin/python3.
Generating the C++ source for the QtCore module...
Embedding sip flags...
Generating [...]
Re-writing
/home/xiaolong/Downloads/PyQt-gpl-5.4/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir...
Generating the top-level .pro file...
Making the pyuic5 wrapper executable...
Generating the Makefiles...因此,PyQt5进入了正确的目录,但实际版本的Qt5已超过5.4。现在,这个问题似乎变成了“如何更新我的Qt5版本?”除非我误解了什么。
编辑#3:
sys.executable输出
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/bin/python3'
>>> 编辑#4:
我的.bash_aliases文件的内容:alias python=python3 alias pip=pip3
发布于 2014-12-30 00:56:17
编辑
我一直认为,在对您的问题的最初评论中提出的建议对您不起作用,所以我猜您的系统上肯定有第二个python安装。但是,在重新阅读了所有的东西之后,你似乎并没有完全理解所有的暗示。
看起来这只是一个dist-packages和site-packages的例子。在基于Debian的系统上,发行版提供的python包安装在dist-packages中,而用户安装的包通常安装在site-packages中。这样做是为了减少破坏依赖于特定版本python包的其他系统应用程序的可能性。
来自PyQt5配置脚本的输出显示您将它安装到site-packages中。
The PyQt5 Python package will be installed in /usr/lib/python3.4/site-packages.但是这个目录没有出现在您的sys.path中,所以python无法从该位置导入包。
有几种方法可以解决这一问题,但有些方法比其他方法“更安全”。例如,您可以以各种方式操作python路径,但这对所有python应用程序(包括使用python2的应用程序)都有很大的负面影响,所以最好避免。
由于依赖PyQt-5.2.1的系统应用程序可能很少,所以可以简单地覆盖它。为此,通过如下配置重新编译和安装PyQt-5.4:
python3 configure.py --destdir=/usr/local/lib/python3.4/dist-packages或者,您可以卸载您的系统PyQt5包(使用apt-get或其他什么),并通过如下配置完全替换它:
python3 configure.py --destdir=/usr/lib/python3/dist-packages作为最后一步,您可能应该通过从PyQt5中删除冗余的/usr/lib/python3.4/site-packages目录来整理事情。
https://stackoverflow.com/questions/27697590
复制相似问题