【问题标题】:pip - Requirement already satisfied?pip - 要求已经满足?
【发布时间】:2026-01-24 03:40:01
【问题描述】:

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 可以通过这个选项吗?
  • 是的——但这不是问题所在。从 virtualenv 1.7 开始, --no-site-packages 已成为默认值并已弃用。我使用的是 1.8.2。无论如何 - 我也试过了,但仍然没有按预期工作......
  • 尝试打印sys.path 看看里面有什么。
  • pip freeze 说什么?

标签: virtualenv pip virtualenvwrapper


【解决方案1】:

已经满意意味着你已经安装了“它”。

尝试: pip 卸载 simplejson

然后: pip install simplejson

【讨论】:

    【解决方案2】:

    您使用sudo 安装simplejson,但如果您使用sudo,您的$PATH 可能会更改,这似乎是问题所在。

    只需使用pip install simplejson(不包括sudo),它可能会起作用。

    仅当您想影响整个系统时才使用sudo

    【讨论】:

    • --user 选项也可能有意义,它将安装在您的~/.local/lib/... 目录中。这不需要 r00t 权限。
    最近更新 更多