我使用的是Ubuntu 14.04。我安装了pyenv
,然后在pyenv
下安装了Python 3.4.2。然后我切换到版本3.4.2:
$ pyenv global 3.4.2
现在我想安装ipython
和qtconsole
:
$ pip install ipython
$ ipython3 qtconsole &
这会给出错误消息(回溯未显示):
ImportError:
Could not load requested Qt binding. Please ensure that
PyQt4 >= 4.7 or PySide >= 1.0.3 is available,
and only one is imported per session.
Currently-imported Qt library: Noneu
PyQt4 installed: False
PySide >= 1.0.3 installed: False
Tried to load: ['pyside', 'pyqt']
然后我尝试了:
$ pip install pyside
给出错误(输出的某些部分被删除):
Installing collected packages: pyside
Running setup.py install for pyside
Removing /tmp/pip_build_hakon/pyside/pyside_package
Python architecture is 64bit
Failed to locate a dynamic Python library, using /home/hakon/.pyenv/versions/3.4.2/lib/libpython3.4m.a
qmake: could not exec '/usr/lib/x86_64-linux-gnu/qt4/bin/qmake': No such file or directory
Failed to query the Qt version with qmake /usr/bin/qmake
更新
从上一条错误消息中我认为我必须这样做
$ sudo apt-get install qt4-qmake
然后我收到一些新的错误消息,导致我运行:
$ sudo apt-get install libxslt-dev
$ sudo apt-get install qt4-default
现在,当我跑:
$ pip install pyside
我收到错误(输出的第一部分被删除):
[ 83%] Building CXX object libshiboken/CMakeFiles/libshiboken.dir/shibokenbuffer.cpp.o
Linking CXX shared library libshiboken.cpython-34m.so
/usr/bin/ld: /home/hakon/.pyenv/versions/3.4.2/lib/libpython3.4m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/home/hakon/.pyenv/versions/3.4.2/lib/libpython3.4m.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
答案 0 :(得分:3)
我想我发现了问题:
PySide构建显然需要一个python ..3.4.so
共享库而不是静态(.a)库,请参阅http://qt-project.org/forums/viewthread/49955。
现在解决方案是卸载Python
$ pyenv uninstall 3.4.2
然后使用共享库支持重新安装Python(另请参阅https://github.com/yyuu/pyenv/issues/82):
$ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.4.2
$ pyenv global 3.4.2
然后安装pyside
$ pip install pyside
然后安装pygments
和pyzmq
:
$ pip install pygments
$ pip install pyzmq
最后,你可以运行它:
$ pip install ipython
$ ipython qtconsole &