Pip 安装到错误的虚拟环境

Pip installing to wrong virtual environment

我有两个 Django 项目,每个项目都有一个名为 myvenv 的虚拟环境。我正在尝试使用 pip 安装一个名为 psycopg2 的包。它正在安装到错误的虚拟环境,即使 which pip 命令确认 pip 正在 运行 正确的虚拟环境中。

我重新启动了 mac 以便在没有任何虚拟环境的情况下启动 运行ning。当我尝试使用 pip 时,我的终端日志看起来像这样:

BillMacBookPro:~ billnoble$ cd ~/documents/yhistory-server
BillMacBookPro:yhistory-server billnoble$ source ~/documents/yhistory-    server/myvenv/bin/activate
(myvenv) BillMacBookPro:yhistory-server billnoble$ which pip
/Users/billnoble/Documents/YHistory-Server/myvenv/bin/pip
(myvenv) BillMacBookPro:yhistory-server billnoble$ brew install postgresql
Warning: postgresql-9.4.4 already installed
Warning: You are using OS X 10.11.
We do not provide support for this pre-release version.
You may encounter build failures or other breakage.
(myvenv) BillMacBookPro:yhistory-server billnoble$ pip install psycopg2
Requirement already satisfied (use --upgrade to upgrade): psycopg2 in /Users/billnoble/Documents/VeeUServer/myvenv/lib/python3.4/site-packages
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

我在 YHistory-Server 目录中成功启动了我的虚拟环境,并且 which pip 确认它是来自该虚拟服务器的 运行ning。但是,当我 运行 pip 时,它会抱怨该软件包安装在我计算机上的另一个虚拟环境中。为什么它使用错误的路径名?我怎样才能让它安装在正确的虚拟环境中?

我认为当您创建第二个 virtualenv 时,您已经激活了第一个,并且可能将它们链接在一起。尝试重新创建您的虚拟环境,并在创建第二个时确保停用您首先创建的第一个。