0
votes

Hello I am using pyenv and its plugin pyenv-virtualenv.

Normally I would install a pyenv first (e.g. pyenv install 3.7.6) and then a virtualenv (e.g. pyenv virtualenv 3.7.6 myenv) and then proceed with pip install.

This time, as the system already features python 3.7, and because I am short of disk space (I'm on a Raspberry Pi 3, with buster), I would like to avoid installing the whole python, but still I would like to isolate in a user-space virtualenv the python packages (numpy, pandas, ecc.). So I would like to define a virtualenv that uses the system python3.

I tried pyenv virtualenv system sysenv but it doesn't work (it claims it can't find pip):

$ pyenv virtualenv system sysenv
Traceback (most recent call last):
  File "/usr/bin/pip", line 7, in <module>
    from pip._internal.main import main
ModuleNotFoundError: No module named 'pip'

which I don't understand, as I have both python-pip and python3-pip apt packages installed.

So: is it possible to create a virtualenv that uses the system python3? What do I miss? Or, is it a bad idea as the system python might be upgraded by apt later?

1

1 Answers

0
votes

You can just use virtualenv without pyenv.

e.g.

$ virtualenv -p $(which python3) sysenv

I can't remember if this command activates the env, so if not you can then run

$ source sysenv/bin/activate