virtualenv does not include pip

  1. virtualenv executable is not placed in /usr/local/bin after pip makes its job, so I need to ln -s it by hand (it may indicate, that there is something wrong with installation on this step).

Don't do that. That will only hide the bug and not solve the problem. Here's a short guide how to debug this kind of issues:

  • Start with which -a python. The first path you see should be /usr/local/bin/python, if not check your PATH variable.

  • Next, check which -a pip. Again the first path should be /usr/local/bin/pip. If not, run python -m ensurepip and recheck.

  • Now install virtualenv using pip install virtualenv, after that check the output of which -a virtualenv. The first path should be /usr/local/bin/virtualenv, if not check the output of env |grep PYTHON for unexpected environment variables.

  • Finally check the output of virtualenv --version to make sure you have the latest version.


I had the issue when running virtualenv: "ImportError: No module named pip." My solution was to downgrade virtualenv. I had 16.2.0. pip uninstall virtualenv pip install virtualenv==15.1.0


Try removing or renaming the .pydistutils.cfg file in your home directory, e.g. by renaming with mv ~/.pydistutils.cfg ~/oldpydistutils.cfg

I'm putting a detailed answer here to help others, but the original credit goes to this answer. If you know what specifically in .pydistutils.cfg was causing the problem, let me know!

I was having the same issue: my virtual environments were created without a local copy of pip, although they had a local copy of python. This meant that using $ pip from within the virtual environment installed to the global package location, and was not visible to the environment's python.

How I diagnosed this on my machine:

  1. I create a virtualenvironment with $ virtualenv env
  2. Activated the virtual environment with $ source env/bin/activate
  3. Checked python location: run (env)$ which python with output /Users/<username>/env/bin/python (as expected)
  4. Checked pip location: run (env)$ which pip with output /usr/local/bin/pip (NOT expected)

To check where our packages are going, we can try to install a package in the virtual environment:

  1. Try to install a package: (env)$ pip install HTTPServer which succeeds
  2. Try to run the package: (env)$ python -m HTTPServer which fails with error /Users/emunsing/env/bin/python: No module named HTTPServer
  3. To double-check, try to install again: (env)$ pip install HTTPServer which produces Requirement already satisfied (use --upgrade to upgrade): HTTPServer in /usr/local/lib/python2.7/site-packages

Double-checking, we see that there's no Pip in the environment's /bin folder:

$ ls env/bin activate activate.fish python python2 activate.csh activate_this.py python-config python2.7

And so while the system finds the local python version, it can't find a local pip to use and traverses the $PATH. It ended up using pip from /usr/local/bin, leaving me unable to install packages locally to the virtual environment.

Here's what I tried: - Reinstalling python brew uninstall python followed by brew upgrade and brew install python --build-from-source - Installing pip using the get-pip.py command as described in the Pip documentation

Here's what I ruled out: - I was not using sudo pip ... which caused similar problems in this other question and haven't done so at any time on this Python/pip install - My virtual environment didn't show a local installation of pip, as was the case in these similar questions: This one for Windows, This one for Mac OS X.

Ultimately, I found that eliminating the ~/.pydistutils.cfg file fixed the problem, allowing for fresh virtual environments that had their own local pip. The contents of my ~/.pydistutils.cfg file were:

[global]
verbose=1

[install]
install-scripts=$HOME/bin

[easy_install]
install-scripts=$HOME/bin

Simply renaming the ~/.pydistutils.cfg file appears to fix the problem: it seems that although this file was created by the homebrew installation, some settings in this file may be incompatible with virtualenv. While removing this file hasn't had any bad effects on my system, you may need to use the --user flag when installing packages with pip to the global environment (e.g. $ pip install --user HTTPServer). Here are more details on .pydistutils.cfg if you want to work on tailoring it for your needs.