由于 ubuntu 存储库中的官方 pyqt5 安装似乎缺乏对 QtQuick 的支持,我尝试从源代码安装 pyqt5。安装本身似乎工作正常,但是在运行使用 PyQt5 的 python 脚本时,python 抱怨它找不到那个 PyQt。
构建 sip 4.15.5 后,我下载了 PyQt5.2。它应该与我的 Qt 版本兼容(的输出qmake --version
):
QMake version 3.0
Using Qt version 5.2.0 in /opt/qt5.1.1/5.2.0/gcc_64/lib
我跑了
pyqt 的 configure.py 的输出可以在这里找到:https ://gist.github.com/Mitmischer/8677889 。
pyqt 的安装输出可以在这里找到:https ://gist.github.com/Mitmischer/8677780 。
之后sudo make install
,我可以看到一个相当不错的文件夹PyQt5
。/usr/lib/python3.3/site-packages
但是,如果我运行 cat PyQt5/__init__.py
,则里面没有实际代码:
# Copyright (c) 2014 Riverbank Computing Limited <info@riverbankcomputing.com>
#
# This file is part of PyQt5.
#
# This file may be used under the terms of the GNU General Public License
# version 3.0 as published by the Free Software Foundation and appearing in
# the file LICENSE included in the packaging of this file. Please review the
# following information to ensure the GNU General Public License version 3.0
# requirements will be met: http://www.gnu.org/copyleft/gpl.html.
#
# If you do not wish to use this file under the terms of the GPL version 3.0
# then you may purchase a commercial license. For more information contact
# info@riverbankcomputing.com.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
是的,这就是该文件中的全部内容。我不知道它是否应该是那样的,但对我来说它看起来很奇怪。此外(ls PyQt5
):
__init__.py QtCore.so QtGui.so QtMultimediaWidgets.so QtPositioning.so QtQuick.so Qt.so QtTest.so QtX11Extras.so
_QOpenGLFunctions_2_0.so QtDBus.so QtHelp.so QtNetwork.so QtPrintSupport.so QtSensors.so QtSql.so QtWebKit.so QtXmlPatterns.so
QtBluetooth.so QtDesigner.so QtMultimedia.so QtOpenGL.so QtQml.so QtSerialPort.so QtSvg.so QtWidgets.so uic/
看起来不像pythonic。
正如其他地方所建议的,我(希望)适当地设置了我的 pythonpath:
> echo $PYTHONPATH
/usr/lib/python3.3/site-packages/
现在,如果我启动交互式python3.3
会话(或脚本),则找不到 PyQt5:
Python 3.3.2+ (default, Oct 9 2013, 14:50:09)
[GCC 4.8.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5 import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQt5'
>>>
有没有其他人试图从源代码安装 PyQt5?我该怎么做才能使 PyQt 工作?