Can't import modules in python: PyQt4 conflicts with SIP
Asked Answered
I

2

1

I'm new and my english is not very well, but here I go: I have the newest Arch Linux on my PC and yesterday I tried to install SIP, a Python code generator for wrapping C++ codes. I tried to install SIP and PyQt4 under a virtual enviroment. I got SIP from the AUR, and installed it this way:

http://lucacerone.net/2013/08/installing-pyqt4-and-sip-in-a-virtual-environment-ubuntu-1204/#.Uyx-dGd_phF/

I did it this way because on the official SIP-documentation website I didn't figure out where to install it and in which directory. The documentation was not clear for me. I know now, that was a very stupid idea because when I try to run a pyhton script with:

python file.py

I got errors because I'm using Python 3.3.4:

[vain@chinchi2 python_programme]$ python test.py
Traceback (most recent call last):
  File "test.py", line 25, in <module>
    import matplotlib.pyplot as plt
  File "/usr/lib/python3.3/site-packages/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/usr/lib/python3.3/site-packages/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/usr/lib/python3.3/site-packages/matplotlib/backends/backend_qt4agg.py", line 13, in <module>
    from .backend_qt4 import QtCore, QtGui, FigureManagerQT, FigureCanvasQT,\
  File "/usr/lib/python3.3/site-packages/matplotlib/backends/backend_qt4.py", line 21, in <module>
    import matplotlib.backends.qt4_editor.figureoptions as figureoptions
  File "/usr/lib/python3.3/site-packages/matplotlib/backends/qt4_editor/figureoptions.py", line 13, in <module>
    import matplotlib.backends.qt4_editor.formlayout as formlayout
  File "/usr/lib/python3.3/site-packages/matplotlib/backends/qt4_editor/formlayout.py", line 51, in <module>
    from matplotlib.backends.qt4_compat import QtGui,QtCore
  File "/usr/lib/python3.3/site-packages/matplotlib/backends/qt4_compat.py", line 56, in <module>
    from PyQt4 import QtCore, QtGui
RuntimeError: the sip module implements API v11.0 but the PyQt4.QtCore module requires API v10.1

What exactly should I change? I also tried:

sudo pacman -S pyqt5-common 5.2-1 [installed]

(Common PyQt files shared between python-pyqt5 and python2-pyqt5) and:

pacman -Sy python-qscintilla-common

Maybe there exists a false library dependency, how can I solve this?


Oh, I want to install PyQt5 but I got the same problem, the same error after I did: python configure.py make sudo make install in the

full/virtualenv/path/build/SIP/sip-4.15.5/ I got the same errors again:

from PyQt4 import QtCore, QtGui RuntimeError: the sip module implements API v11.0 but the PyQt4.QtCore module requires API v10.1 [vain@chinchi2 python_programme]$ python2 erstenprog.py Traceback (most recent call last): File "erstenprog.py", line 26, in <module> import matplotlib.pyplot as plt ImportError: No module named matplotlib.pyplot

I'm so frustraded, because I wrote to arch linux forum in english and german, I got no answer only to deinstalled it.

How I'm supposed to this? I just should follow the advice here: http://lucacerone.net/2013/08/installing-pyqt4-and-sip-in-a-virtual-environment-ubuntu-1204/#.Uyx-dGd_phF/

Shoul I integrate PyQt5 in the:

full/virtualenv/path/build/PyQT5

because it already exists in

lib/python3.3/site-packages/PyQt5.

Inhabitant answered 21/3, 2014 at 20:56 Comment(0)
A
2

If you're new to Arch Linux and don't really know what you're doing: do not install these packages manually!

You can rely on [core]/[community] packages, and on the AUR if some packages are not officially supported.

First: why do you want to install these in a virtualenv? Do you really need a virtualenv for what you plan on doing? Also, do not blindly follow Ubuntu tutorials when you are on Arch Linux, since these are usually not adapted... Ubuntu users will need to get their hands dirty to get the latest features for their software. Not Arch users (rolling release for the win).

Second: the following error

RuntimeError: the sip module implements API v11.0 but the PyQt4.QtCore module requires API v10.1

means that PyQt4.QtCore was not recompiled after the last SIP update. Simply recompiling the package solves the issue. Note that this kind of errors will not happen if you use the official Arch packages.

So, if you want to install PyQt5 with Python 3 on Arch Linux, first remove whatever you did in your virtualenv to prevent clashes, and then:

sudo pacman -S python-pyqt5 sip

After that, running python file.py will call Python 3 with the official properly-installed packages.

Apis answered 7/4, 2014 at 9:36 Comment(0)
D
-1

Are you trying to install PyQt4 or PyQt5?

As you refer to

sudo pacman -S pyqt5-common 5.2-1 [installed]

and try to import PyQt4:

from PyQt4 import QtCore, QtGui

Obviously we are facing the same error: PyQt5 - SIP API 10 level error. API 11 required

Could you please provide your PyQt5 directory content? Just to compare with mine.

I think it's a bug as in the PyQt5 install sip-4.5.15 is required and the latest version available.

... Or PyQt5 uses another sip, but I can't find out any information on such a configuration.

Moreover, I can't find out information regarding the sip packages and their corresponding API level on the web.

I log the installation failures and analysis progress here: http://www.hznteam.fr:5000/trac-bubble/ticket/102

as you I'm waiting for more information.

Dayton answered 23/3, 2014 at 11:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.