简体   繁体   中英

How to install ipython qtconsole with pyenv (Python version 3.4.2)

I am using Ubuntu 14.04. I installed pyenv and then installed Python 3.4.2 under pyenv . Then I switched to version 3.4.2:

$ pyenv global 3.4.2

Now I would like to install ipython and the qtconsole :

$ pip install ipython
$ ipython3 qtconsole &

This gives an error message (traceback not shown):

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']

Then I tried:

$ pip install pyside

which gives error (some parts of output removed):

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

Update

From the previous error message I figured I had to do

$ sudo apt-get install qt4-qmake

And then I got some new error messages, which led me to run:

$ sudo apt-get install libxslt-dev
$ sudo apt-get install qt4-default

Now, when I run:

$ pip install pyside

I get error (first part of output cut out):

[ 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

I think I found the problems:

The PySide build apparently needs a python ..3.4.so shared library and not a static (.a) library see http://qt-project.org/forums/viewthread/49955 .

The solution was now to uninstall Python

$ pyenv uninstall 3.4.2

Then reinstall Python with shared library support (see also https://github.com/yyuu/pyenv/issues/82 ):

$ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.4.2
$ pyenv global 3.4.2

Then install pyside

$ pip install pyside

Then install pygments and pyzmq :

$ pip install pygments
$ pip install pyzmq

And finally, you can run it:

$ pip install ipython
$ ipython qtconsole &

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM