即使我已激活本地virtualenv环境,也会在系统范围的python版本中安装新软件包

时间:2014-10-11 14:33:09

标签: python virtualenv

我已经做了所有内联评论以使我的情况清楚。

我正在尝试创建一个本地虚拟python环境,但没有运气。我使用 - 没有站点包,但仍然可以在本地环境中安装系统范围的包。

我在全球环境中做蛋黄然后我对本地环境结果的蛋黄是一样的。任何见解为什么会发生这种情况?

即使我在本地安装了yolk,它的外观似乎是安装在/usr/local/bin.which是全局的,而不是在我的本地环境中。

ari@awesome:~$ sudo virtualenv python_virt_env/localEnv1 --no-site-packages //I made sure to have clean set up for local env with no system wide packages.
New python executable in python_virt_env/localEnv1/bin/python
Installing setuptools, pip...done.
ari@awesome:~$ sudo source python_virt_env/localEnv1/bin/activate
sudo: source: command not found
ari@awesome:~$ source python_virt_env/localEnv1/bin/activate
(localEnv1)ari@awesome:~$ deactivate


ari@awesome:~$ sudo easy_install yolk // I installed yolk system wide to see system packages
Searching for yolk
Reading https://pypi.python.org/simple/yolk/
Best match: yolk 0.4.3
Downloading https://pypi.python.org/packages/source/y/yolk/yolk-0.4.3.tar.gz#md5=10dfabca7a020058436aec9dbad70123
Processing yolk-0.4.3.tar.gz
Writing /tmp/easy_install-YaODsM/yolk-0.4.3/setup.cfg
Running yolk-0.4.3/setup.py -q bdist_egg --dist-dir /tmp/easy_install-YaODsM/yolk-0.4.3/egg-dist-tmp-Z6MLNg
warning: no files found matching '*.txt' under directory 'tests'
warning: no files found matching '*.conf' under directory 'docs'
warning: no files found matching '*.css_t' under directory 'docs'
warning: no files found matching 'indexsidebar.html' under directory 'docs'
warning: no files found matching 'tests/test_cli.py'
zip_safe flag not set; analyzing archive contents...
Adding yolk 0.4.3 to easy-install.pth file
Installing yolk script to /usr/local/bin     //here you can see yolk being installed system wide.

Installed /usr/local/lib/python2.7/dist-packages/yolk-0.4.3-py2.7.egg
Processing dependencies for yolk
Finished processing dependencies for yolk


ari@awesome:~$ yolk -l // now did listing for system wide packages.
GnuPGInterface  - 0.3.2        - active
Landscape Client - 14.01        - active
PAM             - 0.4.2        - active
Python          - 2.7.6        - active development (/usr/lib/python2.7/lib-dynload)
SecretStorage   - 2.0.0        - active
Twisted Core    - 13.2.0       - active
apt-xapian-index - 0.45         - active
argparse        - 1.2.1        - active development (/usr/lib/python2.7)
chardet         - 2.0.1        - active
colorama        - 0.2.5        - active
configobj       - 4.7.2        - active
env             - 0.1.0        - active development (/usr/local/lib/python2.7/dist-packages)
html5lib        - 0.999        - active
httplib2        - 0.8          - active
iotop           - 0.6          - active
keyring         - 3.5          - active
launchpadlib    - 1.10.2       - active
lazr.restfulclient - 0.13.3       - active
lazr.uri        - 1.0.3        - active
oauth           - 1.0.1        - active
pip             - 1.5.4        - active
pyOpenSSL       - 0.13         - active
pycrypto        - 2.6.1        - active
PyGObject       - 3.12.0       - active
pyserial        - 2.6          - active
python-apt      - 0.9.3.5      - active
python-debian   - 0.1.21-nmu2ubuntu2 - active
requests        - 2.2.1        - active
setuptools      - 3.3          - active
simplejson      - 3.3.1        - active
six             - 1.5.2        - active
ssh-import-id   - 3.21         - active
urllib3         - 1.7.1        - active
virtualenv 1.11.6 has no metadata
wadllib         - 1.3.2        - active
wsgiref         - 0.1.2        - active development (/usr/lib/python2.7)
yolk            - 0.4.3        - active development (/usr/local/lib/python2.7/dist-packages/yolk-0.4.3-py2.7.egg)
zope.interface  - 4.0.5        - active


ari@awesome:~$ source python_virt_env/localEnv1/bin/activate // Now i activated the local env
(localEnv1)ari@awesome:~$ sudo easy_install yolk //locally installed yolk
Searching for yolk
Best match: yolk 0.4.3
Processing yolk-0.4.3-py2.7.egg
yolk 0.4.3 is already the active version in easy-install.pth
Installing yolk script to /usr/local/bin   //but still yolk is being installed on global python directory and not in python_virt_env/localEnv1/bin/ why?

Using /usr/local/lib/python2.7/dist-packages/yolk-0.4.3-py2.7.egg
Processing dependencies for yolk
Finished processing dependencies for yolk


(localEnv1)ari@awesome:~$ yolk -l // now i did yolk locally but still it shows all system wide packages.what I am doing wrong here?
GnuPGInterface  - 0.3.2        - active
Landscape Client - 14.01        - active
PAM             - 0.4.2        - active
Python          - 2.7.6        - active development (/usr/lib/python2.7/lib-dynload)
SecretStorage   - 2.0.0        - active
Twisted Core    - 13.2.0       - active
apt-xapian-index - 0.45         - active
argparse        - 1.2.1        - active development (/usr/lib/python2.7)
chardet         - 2.0.1        - active
colorama        - 0.2.5        - active
configobj       - 4.7.2        - active
env             - 0.1.0        - active development (/usr/local/lib/python2.7/dist-packages)
html5lib        - 0.999        - active
httplib2        - 0.8          - active
iotop           - 0.6          - active
keyring         - 3.5          - active
launchpadlib    - 1.10.2       - active
lazr.restfulclient - 0.13.3       - active
lazr.uri        - 1.0.3        - active
oauth           - 1.0.1        - active
pip             - 1.5.4        - active
pyOpenSSL       - 0.13         - active
pycrypto        - 2.6.1        - active
PyGObject       - 3.12.0       - active
pyserial        - 2.6          - active
python-apt      - 0.9.3.5      - active
python-debian   - 0.1.21-nmu2ubuntu2 - active
requests        - 2.2.1        - active
setuptools      - 3.3          - active
simplejson      - 3.3.1        - active
six             - 1.5.2        - active
ssh-import-id   - 3.21         - active
urllib3         - 1.7.1        - active
virtualenv 1.11.6 has no metadata
wadllib         - 1.3.2        - active
wsgiref         - 0.1.2        - active development (/usr/lib/python2.7)
yolk            - 0.4.3        - active development (/usr/local/lib/python2.7/dist-packages/yolk-0.4.3-py2.7.egg)
zope.interface  - 4.0.5        - active
(localEnv1)ari@awesome:~$

1 个答案:

答案 0 :(得分:0)

在python中使用虚拟环境的正确方法如下:

mkdir somefolder
cd somefolder
virtualenv venv
source ./venv/bin/activate
pip install yolk
...do some more stuff...
deactivate

使用virtualenv

时,您不需要sudo