[英]in `pyenv/pyenv-virtualenv` can I create a virtualenv which refers to `system`, i.e. without a `pyenv install` before?
Hello I am using pyenv and its plugin pyenv-virtualenv .您好,我正在使用pyenv及其插件pyenv-virtualenv 。
Normally I would install a pyenv first (eg pyenv install 3.7.6
) and then a virtualenv (eg pyenv virtualenv 3.7.6 myenv
) and then proceed with pip install
.通常我会先安装一个 pyenv(例如
pyenv install 3.7.6
)然后是一个 virtualenv(例如pyenv virtualenv 3.7.6 myenv
)然后继续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.).这一次,由于系统已经配备了python 3.7,并且由于我的磁盘空间不足(我在Raspberry Pi 3上,带有
buster
),我想避免安装整个python,但我仍然想隔离在用户空间 virtualenv 中,python 包(numpy、pandas、ecc)。 So I would like to define a virtualenv that uses the system python3.所以我想定义一个使用系统python3的virtualenv。
I tried pyenv virtualenv system sysenv
but it doesn't work (it claims it can't find pip):我试过
pyenv virtualenv system sysenv
但它不起作用(它声称它找不到 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.我不明白,因为我同时安装了
python-pip
和python3-pip
apt 包。
So: is it possible to create a virtualenv that uses the system python3?那么:是否可以创建一个使用系统 python3 的 virtualenv? What do I miss?
我想念什么? Or, is it a bad idea as the system python might be upgraded by apt later?
或者,这是一个坏主意,因为系统 python 可能稍后会被 apt 升级?
You can just use virtualenv without pyenv.你可以只使用 virtualenv 而没有 pyenv。
eg例如
$ 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.