1

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

Morten Nissov
  • 392
  • 3
  • 13

2 Answers2

2

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

-1

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

abhigyanj
  • 2,355
  • 2
  • 9
  • 29
  • 1
    why would i use pip3 in a python3 virtual env and not just pip? My understanding was that in the venv that pip should default to the venv python version, which is also verified by checking `pip -V` – Morten Nissov Oct 17 '20 at 11:00
  • 1
    Also for what it matters, just tried the same using `pip3 install sip` and then `python3` followed by `import sip` with the same results – Morten Nissov Oct 17 '20 at 11:06
  • @MortenNissov Activate your virtual env – abhigyanj Oct 17 '20 at 11:11
  • 1
    My bad for not mentioning this but everything has been with the venv activated, I have edited the original post and added this as a comment – Morten Nissov Oct 17 '20 at 11:42