0

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?

lurix66
  • 502
  • 1
  • 5
  • 14

1 Answers1

0

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
Hitobat
  • 2,847
  • 1
  • 16
  • 12
  • Thanks @Hitobat, I am with `pyenv` and `pyenv-virtualenv` plugin (see links in the question), so I can't use that same command. I tried with `$ pyenv virtualenv -p system sysenv` and I get the answer `pyenv-virtualenv: 'system' is not installed in pyenv.` If I omit the `-p` option, it goes even worse: `pyenv: pip: command not found` – lurix66 Feb 03 '20 at 12:25