Python virtualenv error when calling easy_install

If you see the following exception when trying to set up a Python virtualenv environment on Mac OS X (or possibly other OSes), the culprit is usually the contents of .pydistutils.cfg.

$ virtualenv flaskenv
New python executable in flaskenv/bin/python
Please make sure you remove any previous custom paths from your /Users/account/.pydistutils.cfg file.
Installing setuptools.............done.
Installing pip....
Complete output from command /Users/account/devsrc/flaskenv/bin/python -x /Users/account/devs...env/bin/easy_install /Users/account/Libr...ort/pip-1.2.1.tar.gz:
/Users/account/devsrc/flaskenv/bin/python: can't open file '/Users/account/devsrc/flaskenv/bin/easy_install': [Errno 2] No such file or directory
----------------------------------------
...Installing pip...done.
Traceback (most recent call last):
File "/Users/account/bin/virtualenv", line 8, in
load_entry_point('virtualenv==1.8.2', 'console_scripts', 'virtualenv')()
File "/Users/account/Library/Python/2.7/site-packages/virtualenv.py", line 942, in main
never_download=options.never_download)
File "/Users/account/Library/Python/2.7/site-packages/virtualenv.py", line 1054, in create_environment
install_pip(py_executable, search_dirs=search_dirs, never_download=never_download)
File "/Users/account/Library/Python/2.7/site-packages/virtualenv.py", line 655, in install_pip
filter_stdout=_filter_setup)
File "/Users/account/Library/Python/2.7/site-packages/virtualenv.py", line 1020, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/account/devsrc/flaskenv/bin/python -x /Users/account/devs...env/bin/easy_install /Users/account/Libr...ort/pip-1.2.1.tar.gz failed with error
code 2

You’ve just gotta comment out the settings in .pydistutils.cfg:

$ cat ~/.pydistutils.cfg
#[install]
#install_lib = ~/Library/Python/$py_version_short/site-packages
#install_scripts = ~/bin

Then everything works as expected:

$ virtualenv flaskenv
New python executable in flaskenv/bin/python
Please make sure you remove any previous custom paths from your /Users/account/.pydistutils.cfg file.
Installing setuptools............done.
Installing pip...............done.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.