pip - 需求已满足?

17

pip 识别全局安装的包..?! :-(

我使用 virtualenvwrapper 的 preactivate hook 清理 PYTHONPATH,

export PYTHONPATH="" 

然后执行 echo $PYTHONPATH 返回一个空字符串,但这并没有帮助解决问题。

问题出在哪里?

bentzy@lama:~$ mkvirtualenv test
New python executable in test/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /home/bentzy/.virtualenvs/test/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/bentzy/.virtualenvs/test/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/bentzy/.virtualenvs/test/bin/preactivate
virtualenvwrapper.user_scripts creating /home/bentzy/.virtualenvs/test/bin/postactivate
virtualenvwrapper.user_scripts creating /home/bentzy/.virtualenvs/test/bin/get_env_details
(test)bentzy@lama:~$ which pip
/home/bentzy/.virtualenvs/test/bin/pip
(test)bentzy@lama:~$ sudo pip install simplejson
Requirement already satisfied (use --upgrade to upgrade): simplejson in /usr/lib    /python2.7/dist-packages
Cleaning up...
(test)bentzy@lama:~$ echo $PYTHONPATH

(test)bentzy@lama:~$ pip --version
pip 1.2.1 from /home/bentzy/.virtualenvs/test/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg (python 2.7)

我没有使用virtualenvwrapper,但是在使用virtualenv时,我会使用--no-site-packages选项。mkvirtualenv可以传递这个选项吗? - Shawn H
是的 - 但这不是问题所在。从virtualenv 1.7开始,--no-site-packages已成为默认设置并已被弃用。我正在使用1.8.2。 无论如何,我也尝试过了,但仍然没有按预期工作... - bentzy
尝试打印 sys.path 并查看其中的内容。 - Aman
pip freeze 会输出什么? - Bibhas Debnath
2个回答

19
你正在使用sudo安装simplejson,但如果你使用sudo,你的$PATH可能会被更改,这似乎就是问题所在。
只需使用pip install simplejson(不包括sudo),它可能会起作用。
只有当您想要影响整个系统时才使用sudo

1
此外,“--user”选项可能是有意义的,它将安装在您的“~/.local/lib/…”目录中。这不需要r00t权限。 - kmiklas

12

已满意意味着您已经安装了 "it"。

尝试: pip uninstall simplejson

然后: pip install simplejson


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接