简体   繁体   中英

Pip installing to wrong virtual environment

I have two Django projects each with a virtual environment called myvenv . I am trying to use pip to install a package called psycopg2. It is installing to the wrong virtual environment even though the which pip command confirms that pip is being run within the correct virtual environment.

I rebooted my mac so as to start without any virtual environments running. My terminal log looks like this when I try to use 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.

I am successfully starting my virtual environment in the YHistory-Server directory and which pip confirms that it is running from this virtual server. However when I run pip it complains that the package is installed in another virtual environment on my computer. Why is it using the wrong path name? How can I make it install in the correct virtual environment?

I think when you created your second virtualenv you did so with the first already activated, and possibly chained them together. Try to recreate your virtual environments, and when you create the second one make sure you deactivate the first one you created first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM