简体   繁体   English

无法在python中导入模块:PyQt4与SIP冲突

[英]Can't import modules in python: PyQt4 conflicts with SIP

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. 我是新手,英语不是很好,但是我去了:我的PC上有最新的Arch Linux,昨天我尝试安装SIP,这是一个用于包装C ++代码的Python代码生成器。 I tried to install SIP and PyQt4 under a virtual enviroment. 我试图在虚拟环境下安装SIP和PyQt4。 I got SIP from the AUR, and installed it this way: 我从AUR获得了SIP,并以这种方式安装它:

http://lucacerone.net/2013/08/installing-pyqt4-and-sip-in-a-virtual-environment-ubuntu-1204/#.Uyx-dGd_phF/ 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. 我这样做是因为在SIP官方文档的官方网站上,我不知道该在何处以及在哪个目录中进行安装。 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: 我现在知道,这是一个非常愚蠢的主意,因为当我尝试使用以下命令运行pyhton脚本时:

python file.py

I got errors because I'm using Python 3.3.4: 因为使用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: (在python-pyqt5和python2-pyqt5之间共享的常见PyQt文件)和:

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 哦,我想安装PyQt5,但这样做后却遇到了相同的问题,同样的错误: python configure.py make sudo make install in

full/virtualenv/path/build/SIP/sip-4.15.5/ I got the same errors again: full/virtualenv/path/build/SIP/sip-4.15.5/我再次遇到相同的错误:

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. 我非常沮丧,因为我用英语和德语写信给arch linux论坛,仅卸载它就没有任何答案。

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/ 我只是应该遵循以下建议: http : //lucacerone.net/2013/08/installing-pyqt4-and-sip-in-a-virtual-environment-ubuntu-1204/#.Uyx-dGd_phF/

Shoul I integrate PyQt5 in the: Shoul我将PyQt5集成到:

full/virtualenv/path/build/PyQT5

because it already exists in 因为它已经存在于

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

If you're new to Arch Linux and don't really know what you're doing: do not install these packages manually! 如果您是Arch Linux的新手,并且真的不知道自己在做什么:请不要手动安装这些软件包!

You can rely on [core]/[community] packages, and on the AUR if some packages are not officially supported. 您可以依赖[core]/[community]软件包,如果某些软件包不受官方支持,则可以依赖AUR。

First: why do you want to install these in a virtualenv? 第一:为什么要将它们安装在virtualenv中? Do you really need a virtualenv for what you plan on doing? 您真的需要virtualenv来实现您的计划吗? 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. 另外,当您使用Arch Linux时,请不要盲目地遵循Ubuntu教程,因为这些教程通常无法适应... Ubuntu用户将需要动手以获取其软件的最新功能。 Not Arch users (rolling release for the win). 不是Arch用户(获胜的滚动发布)。

Second: the following error 第二:以下错误

RuntimeError: the sip module implements API v11.0 but the PyQt4.QtCore module requires API v10.1 RuntimeError:sip模块实现API v11.0,但PyQt4.QtCore模块需要API v10.1

means that PyQt4.QtCore was not recompiled after the last SIP update. 表示在上次SIP更新后未重新编译PyQt4.QtCore Simply recompiling the package solves the issue. 只需重新编译软件包即可解决此问题。 Note that this kind of errors will not happen if you use the official Arch packages. 请注意,如果使用官方Arch软件包,则不会发生此类错误。

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: 因此,如果您想在Arch Linux上使用Python 3安装PyQt5,请首先删除您在virtualenv中所做的一切以防止冲突,然后:

sudo pacman -S python-pyqt5 sip

After that, running python file.py will call Python 3 with the official properly-installed packages. 之后,运行python file.py将调用带有正确安装的官方软件包的Python 3。

Are you trying to install PyQt4 or PyQt5? 您是否要安装PyQt4或PyQt5?

As you refer to 如你所指

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

and try to import PyQt4: 并尝试导入PyQt4:

from PyQt4 import QtCore, QtGui

Obviously we are facing the same error: PyQt5 - SIP API 10 level error. 显然,我们面临着相同的错误: PyQt5-SIP API 10级错误。 API 11 required 需要API 11

Could you please provide your PyQt5 directory content? 您能否提供您的PyQt5目录内容? 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. 我认为这是一个错误,因为需要在PyQt5中安装sip-4.5.15并提供最新版本。

... Or PyQt5 uses another sip, but I can't find out any information on such a configuration. ...或者PyQt5使用另一个Sip,但是我找不到有关这种配置的任何信息。

Moreover, I can't find out information regarding the sip packages and their corresponding API level on the web. 而且,我无法在Web上找到有关sip包及其相应API级别的信息。

I log the installation failures and analysis progress here: http://www.hznteam.fr:5000/trac-bubble/ticket/102 我在此处记录了安装失败和分析进度: http : //www.hznteam.fr :5000/trac-bubble/ticket/ 102

as you I'm waiting for more information. 当您等待更多信息时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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