Pip 安装到错误的虚拟环境

Bil*_*ble 3 python django macos virtualenv

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

我重新启动了我的 Mac,以便在没有运行任何虚拟环境的情况下启动。当我尝试使用 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.
Run Code Online (Sandbox Code Playgroud)

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

iro*_*ggy 5

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