【发布时间】:2023-12-03 04:25:02
【问题描述】:
我有两个 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.
我在 YHistory-Server 目录中成功启动了我的虚拟环境,which pip 确认它正在此虚拟服务器上运行。但是,当我运行 pip 时,它抱怨该软件包安装在我计算机上的另一个虚拟环境中。为什么它使用错误的路径名?如何让它安装在正确的虚拟环境中?
【问题讨论】:
-
在激活 virtualenv 前后共享
echo $PYTHONPATH的输出 -
运行 echo $PYTHONPATH 时没有任何反应
标签: python django macos virtualenv