简体   繁体   English

PyQt5:ImportError:没有名为sip的模块

[英]PyQt5: ImportError: No module named sip

This has me completely bamboozled. 这使我完全措手不及。 I wanted to compile PyQt5. 我想编译PyQt5。 To do that I first need to compile and install sip. 为此,我首先需要编译并安装sip。 So I compiled and installed sip. 所以我编译并安装了SIP。 Then I compiled and installed PyQt5. 然后,我编译并安装了PyQt5。 No problems so far. 到目前为止没有问题。 Then I tried it out. 然后我尝试了。

$ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sip
>>> import PyQt5
>>> from PyQt5 import QtCore
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named sip
>>> 

What??? 什么??? I had to have sip installed to compile PyQt5. 我必须安装sip才能编译PyQt5。 I had to have sip installed to import it. 我必须安装sip才能导入它。 Why is it now telling me that there is "No module named sip?" 为什么现在告诉我“没有名为sip的模块”?

I had this problem with system packages (installed via apt), with a virtual env created with --system-site-packages , and I don't have it inside a proper virtual env. 我在系统软件包(通过apt安装),使用--system-site-packages创建的虚拟环境中遇到了这个问题,而我在适当的虚拟环境中没有它。 Python3.6, LinuxMint 19. Python3.6,LinuxMint 19。

I had this problem when I was inside (venv) running the python from the venv/bin 我在(venv)从venv / bin运行python时遇到了这个问题

it cleared and found sip when I used usr/bin/python 当我使用usr / bin / python时,它清除并找到了sip

(in my setup they were the same versions, please check you product and setup that the virtual py is not needed) (在我的设置中,它们是相同的版本,请检查您的产品并设置为不需要虚拟py)

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

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