Issue
I followed instructions to install a wheel while my virtualenv was active. When I went to use it I found it wasn't available but when I deactivated the venv it was, so it appears that although the venv was active during the install the package was installed into 'plain old python'.
How can I install a wheel and have it installed into the venv ?
The instructions I used are here and this is the transcript of what I did ...
(venv) glaucon@rome:/tmp/stpyv8$ ll
total 18380
drwxrwxr-x 2 glaucon glaucon 4096 May 23 17:49 ./
drwxrwxrwt 42 root root 16384 May 23 17:49 ../
-rw-rw-r-- 1 glaucon glaucon 18797973 May 23 17:49 stpyv8-ubuntu-20.04-python-3.9.zip
(venv) glaucon@rome:/tmp/stpyv8$ unzip stpyv8-ubuntu-20.04-python-3.9.zip
Archive: stpyv8-ubuntu-20.04-python-3.9.zip
inflating: stpyv8-ubuntu-20.04-3.9/icudtl.dat
inflating: stpyv8-ubuntu-20.04-3.9/stpyv8-11.3.244.11-cp39-cp39-linux_x86_64.whl
(venv) glaucon@rome:/tmp/stpyv8$ cd stpyv8-ubuntu-20.04-3.9/
(venv) glaucon@rome:/tmp/stpyv8/stpyv8-ubuntu-20.04-3.9$ ll
total 24384
drwxrwxr-x 2 glaucon glaucon 4096 May 23 17:50 ./
drwxrwxr-x 3 glaucon glaucon 4096 May 23 17:50 ../
-rw-r--r-- 1 glaucon glaucon 10542048 May 17 15:27 icudtl.dat
-rw-r--r-- 1 glaucon glaucon 14416203 May 17 15:27 stpyv8-11.3.244.11-cp39-cp39-linux_x86_64.whl
(venv) glaucon@rome:/tmp/stpyv8/stpyv8-ubuntu-20.04-3.9$ popd
/usr/share ~/dev/orientation-stpyv8-sandbox/stpyv8
(venv) glaucon@rome:/usr/share$ cd stpyv8/
(venv) 1 glaucon@rome:/usr/share/stpyv8$ sudo cp -v /tmp/stpyv8/stpyv8-ubuntu-20.04-3.9/icudtl.dat .
'/tmp/stpyv8/stpyv8-ubuntu-20.04-3.9/icudtl.dat' -> './icudtl.dat'
(venv) glaucon@rome:/usr/share/stpyv8$ ll
total 10312
drwxr-xr-x 2 root root 4096 May 23 17:51 ./
drwxr-xr-x 277 root root 12288 May 23 17:46 ../
-rw-r--r-- 1 root root 10542048 May 23 17:51 icudtl.dat
(venv) glaucon@rome:/usr/share/stpyv8$ popd
~/dev/orientation-stpyv8-sandbox/stpyv8
(venv) glaucon@rome:~/dev/orientation-stpyv8-sandbox/stpyv8$ sudo pip install --upgrade /tmp/stpyv8/stpyv8-ubuntu-20.04-3.9/stpyv8-11.3.244.11-cp39-cp39-linux_x86_64.whl
Processing /tmp/stpyv8/stpyv8-ubuntu-20.04-3.9/stpyv8-11.3.244.11-cp39-cp39-linux_x86_64.whl
Installing collected packages: stpyv8
Successfully installed stpyv8-11.3.244.11
When I then try to use it it's available without the venv being active ...
glaucon@rome:~/dev/orientation-stpyv8-sandbox$ python3
Python 3.9.16 (main, Dec 7 2022, 01:11:51)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import STPyV8
>>> exit()
... but not with the venv being active ...
glaucon@rome:~/dev/orientation-stpyv8-sandbox$ . ./venv/bin/activate
(venv) glaucon@rome:~/dev/orientation-stpyv8-sandbox$ python
Python 3.9.16 (main, Dec 7 2022, 01:11:51)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import STPyV8
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'STPyV8'
>>> exit()
(venv) glaucon@rome:~/dev/orientation-stpyv8-sandbox$
I presume there is a way to install wheels into venvs ? Can anyone tell me how please ?
Solution
- Uninstall the globally installed package (
pip uninstall -y stpyv8
) so it's not messing things up. - Install the package into the venv, but without
sudo
. You don't needsudo
to install into a venv (and in general not unless you need a system-wide installation anyway). To be explicit, you can also dovenv/bin/pip install ....
.
Answered By - AKX Answer Checked By - Candace Johnson (WPSolving Volunteer)