Setting up a virtural enviroment (venv) with no system site packages

本小妞迷上赌 提交于 2019-12-08 07:53:02

问题


I want to create a virtual environment using Enthought's Canopy distribution, but with no site packages.

following: https://support.enthought.com/entries/21802240-Use-venv-not-virtualenv-with-Canopy-Python

I set up the environment, leaving off the -s to not install the site packages:

$ venv path/to/virtual_environment_dir
$ source path/to/virtual_environment_dir/bin/activate

And this uses the correct python, but still uses the system easy_install and pip

(env) $ which python
path/to/virtual_environment_dir/bin/python
(env) $ which easy_install
/usr/bin/easy_install
(env) $ which pip
/usr/local/bin/pip

So if I try to install anything, it just installs it globally.

Is there any way to install pip into the virtual environment?


回答1:


You have to install setuptools and pip manually into the environment. venv in Canopy is backported from the venv in Python 3, so unlike virtualenv, it has no special support for pre-installing these packages into the new environment. Just follow the standard installation instructions for setuptools and pip using the new environment's python executable.




回答2:


This is from Robert Kern's reply, I just keep having to look up the command so I'll post it here.

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py -O - | python


来源:https://stackoverflow.com/questions/17976993/setting-up-a-virtural-enviroment-venv-with-no-system-site-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!