Problem importing sip after successful installation

4k views Asked by At

Using python 3.6 in a virtual environment created by python3 -m venv env_name I need to use the python sip module.

I activate the venv by source env_name/bin/activate

I install this successfully by pip install sip which results in

Installing collected packages: packaging, sip
Successfully installed packaging-20.4 sip-5.4.0

Afterwards I can check that sip appears in pip by

$ pip list | grep sip
sip                           5.4.0

After all of this I try to use sip by opening python and importing it with the following error:

$ python 
Python 3.6.9 (default, Oct  8 2020, 12:12:24) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sip
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'sip'
>>> 

If I try the same outside the virtualenv it works fine, am I creating the virtualenv incorrectly?

edit: this is on ubuntu 18.04 LTS with python 3.6.9

2

There are 2 answers

4
wind On

Make sure you use pip3 not pip. So you need you basically run pip3 install sip

0
JohnnyWaker On

The sip module you would probably need is the module that supports pyqt5 or the latest pyqt6.

Installation with:

pip install pyqt6-sip

and the import with

from PyQt6 import sip

The stand-alone sip itself is a command line tool: Docu can be found here