简体   繁体   English

即使我已激活本地virtualenv环境,新软件包也将以系统级python版本安装。

[英]New Packages are being installed in system wide python version even when I have activated the local virtualenv environment

I have made all inline comments to make my situation clear. 我已经做出了所有内联评论,以使我的情况更加清楚。

I am trying to create a local virtual python enviroment but no luck.I use -- no site packages but still get system wide packages being installed in local env. 我正在尝试创建一个本地虚拟python环境,但是没有运气。我使用-没有站点软件包,但仍然在本地env中安装了系统范围的软件包。

I do yolk on global environment and then I do yolk on local environment results are same.Any insights why this might happened? 我在全球环境中做蛋黄,然后在本地环境中做蛋黄。为什么会有这种见解?

Even when I installed yolk locally its look like it is being installed on /usr/local/bin.which is global and not in my local env. 即使我在本地安装了蛋黄,它的外观也似乎安装在/usr/local/bin.global上,而不是在我的本地环境中。

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:~$

The correct way of using a virtual environment in python is as follows: 在python中使用虚拟环境的正确方法如下:

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

You don't need sudo when using a virtualenv 使用virtualenv时不需要sudo

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Ubuntu 12.04中创建python virtualenv在本地venv软件包之前访问系统安装的python软件包 - Creating a python virtualenv in Ubuntu 12.04 accessing system installed python packages before local venv packages python virtualenv没有被激活 - python virtualenv is not being activated python 脚本正在寻找系统环境,即使虚拟环境已激活 - python script is looking to system environment even though virtual environment is activated 使用 Python virtualenv --system-site-packages 安装本地包 - Installing local packages with Python virtualenv --system-site-packages 无法识别新的 Python 版本。 我安装了新的 python 版本,但是当我尝试安装软件包时出现错误 - New Python version not recognised. I installed the new python version but I get an Error when I try to install packages 在PyCharm的virtualenv中排除系统范围的软件包 - Excluding system-wide packages in a virtualenv in PyCharm 当 python package 安装在本地计算机上而不是 virtualenv 中时,如何在 virtualenv 上安装 pytest? - How do I install pytest on virtualenv when the python package is installed on the local machine and not in the virtualenv? 如何将本地 python 环境(+所有包)克隆到 virtualenv 中? - How to CLONE LOCAL python environment (+ALL packages) into virtualenv? 使用先前选择的python软件包创建新的virtualenv - Create new virtualenv with selected previously installed python packages 新创建的virtualenv未被激活,但是旧的 - new created virtualenv not being activated but old
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM