如何使用pyenv安装ipython qtconsole(Python版本3.4.2)

时间:2015-01-27 07:55:26

标签: python python-3.x ipython pyside

我使用的是Ubuntu 14.04。我安装了pyenv,然后在pyenv下安装了Python 3.4.2。然后我切换到版本3.4.2:

$ pyenv global 3.4.2

现在我想安装ipythonqtconsole

$ 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

1 个答案:

答案 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

然后安装pygmentspyzmq

$ pip install pygments
$ pip install pyzmq

最后,你可以运行它:

$ pip install ipython
$ ipython qtconsole &