Why does pip installs a package outside my virtual environment?

I ran into this problem when I renamed the directory containing my virtual environment. The hard path pip was using was no longer correct.

Update the shebang in the pip script to point to your virtual environment's python executable.


In my opinion, either you are executing a pip that is not part of the virtualenv, or you are, but the python interpreter that gets executed is not part of the virtualenv. Check if the pip you are executing is the right one with which pip, and force the python from the virtualenv by using your_envdir/bin/python pip <arguments>, instead of just invoking plain pip.

This is strange, because if you correctly activated the environment with bin/activate, you should get the correct pip. Are you sure you activated with . bin/activate, and not sh bin/activate ? They are two different things. Did the prompt change ?