Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
即使我已经激活了本地VirtualEnvironment,新的软件包也将安装在系统范围的python版本中_Python_Virtualenv - Fatal编程技术网

即使我已经激活了本地VirtualEnvironment,新的软件包也将安装在系统范围的python版本中

即使我已经激活了本地VirtualEnvironment,新的软件包也将安装在系统范围的python版本中,python,virtualenv,Python,Virtualenv,我已经发表了所有内联评论,以明确我的处境 我正在尝试创建一个本地虚拟python环境,但运气不好。我使用--没有站点包,但仍然在本地环境中安装了系统范围的包 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 execu

我已经发表了所有内联评论,以明确我的处境

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

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:~$
我对全球环境做了分析,然后对当地环境做了分析,结果都是一样的。有什么见解可以解释为什么会发生这种情况吗

即使我在本地安装了yolk,它看起来也像是安装在/usr/local/bin.上,它是全局的,而不是本地环境中的

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

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

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

当使用virtualenv时,你不需要
sudo
,你可能想做
yolk-a
而不是
yolk-l
(我不知道
yolk
,只是看了他们的页面).yolk-a也会产生相同的结果,因为所有包都处于活动状态。我再次重拨了所有内容,现在一切看起来都很好。我不知道最初发生了什么。谢谢