virtualenv fails - setuptools pip wheel failed with error code 2

Created on 24 Feb 2016  ·  11Comments  ·  Source: pypa/virtualenv

I'm runningon Ubuntu-12.04:

pip --version
pip 8.0.2 from /usr/local/lib/python2.7/dist-packages (python 2.7)

virtualenv --version
14.0.6

virtualenv fails to create the environment. I don't know why it thinks it's supposed to use pip 7.0.1, when pip 8.0.2 is installed.
I tried reinstalling pip (i.e. removing the apt package, installing via ez_setup), virtualenv - nothing worked.
On other machines 14.0.6 worked well, it's just this one that's giving me a hard time.
Any help would be appreciated!

I'm enclosing the log, and following, the pip environment:

log

virtualenv --system-site-packages /tmp/venv
New python executable in /tmp/venv/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /tmp/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
  You are using pip version 7.0.1, however version 8.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting setuptools
/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
Exception:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 223, in main
    status = self.run(options, args)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 291, in run
    wb.build(autobuilding=True)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/wheel.py", line 704, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 317, in prepare_files
    functools.partial(self._prepare_file, finder))
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 304, in _walk_req_to_install
    more_reqs = handler(req_to_install)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 439, in _prepare_file
    req_to_install.populate_link(finder, self.upgrade)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/req/req_install.py", line 244, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/index.py", line 486, in find_requirement
    all_versions = self._find_all_versions(req.name)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/index.py", line 435, in _find_all_versions
    formats = fmt_ctl_formats(self.format_control, canonical_name)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv_support/pip-7.0.1-py2.py3-none-any.whl/pip/index.py", line 1260, in fmt_ctl_formats
    if canonical_name in fmt_ctl.only_binary:
AttributeError: 'str' object has no attribute 'only_binary'

----------------------------------------

...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 705, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 924, in create_environment
    download=download,
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 877, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 783, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /tmp/venv/bin/python -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 2

pip list

APScheduler (2.1.2)
apt-xapian-index (0.44)
boto (2.2.2)
chardet (2.0.1)
Cheetah (2.4.4)
cloud-init (0.6.3)
command-not-found (0.2.44)
configobj (4.7.2)
demjson (1.6)
distribute (0.6.24dev-r0)
euca2ools (2.0.0)
futures (2.2.0)
GnuPGInterface (0.3.2)
google-api-python-client (1.3.1)
httplib2 (0.9)
iotop (0.4.4)
keyring (0.9.2)
Landscape-Client (14.12)
language-selector (0.1)
launchpadlib (1.9.12)
lazr.restfulclient (0.12.0)
lazr.uri (1.0.3)
lxml (3.2.3)
M2Crypto (0.21.1)
Markdown (2.6.5)
oauth (1.0.1)
oauth2client (1.4.6)
PAM (0.4.2)
paramiko (1.7.7.1)
pika (0.9.14)
pip (8.0.2)
pyasn1 (0.1.7)
pyasn1-modules (0.0.5)
pycrypto (2.6.1)
pycurl (7.19.5)
pyes (0.99.6)
pymongo (2.8)
pyOpenSSL (0.12)
pyserial (2.5)
python-apt (0.8.3ubuntu7.3)
python-debian (0.1.21ubuntu1)
PyYAML (3.10)
pyzabbix (0.7.2)
requests (2.5.1)
rsa (3.1.4)
setuptools (18.7)
simplejson (3.6.5)
six (1.9.0)
tabulate (0.7.5)
thrift (0.9.0)
tinys3 (0.1.11)
tldextract (1.2.2)
Twisted-Core (11.1.0)
Twisted-Web (11.1.0)
ufw (0.31.1.post1)
unattended-upgrades (0.1)
unicodecsv (0.9.4)
uritemplate (0.6)
urllib3 (1.10)
virtualenv (13.1.0)
wadllib (1.3.0)
wheel (0.29.0)
XlsxWriter (0.7.2)
zbxsend (0.1.6)
zope.interface (3.6.1)

Most helpful comment

1) Try installing pysocks - sudo pip install pysocks
2) Use - unset all_proxy
3) Retry

All 11 comments

I'm not sure how you can possibly have a virtualenv which emits 14.0.6. for its version but has bad old wheels in dist-packages/virtualenv_support. I would suggest removing all virtualenv* things in /usr/local/lib/python2.7/dist-packages/ and reinstalling it.

Thanks @Ivoz, this did the trick.
I have no idea how it got this way - we're using chef, and the cookbook keeps the versions pretty much up to date.

I got same problem than I find that all this is happening because of the setuptools and wheels than:
1.I have uninstall setuptools and wheels from pip

  1. also from the "apt-get remove wheel setuptools virutalenv (if they exist in my case wheels and setuptools both were existed and may be conflicting each other from pip and apt-get installations)
  2. download fresh > setuptools-35.0.2 from https://pypi.python.org/pypi/setuptools#downloads

virutalenv-15.1.0 from https://pypi.python.org/pypi/virtualenv

  1. install both the tools freshly
  2. this method solved my problem both in my Desktop and laptop.

1) Try installing pysocks - sudo pip install pysocks
2) Use - unset all_proxy
3) Retry

This will solve...
export all_proxy=https://proxy_here:port_here/

@skylather this solved my issue.... thanks

@skylather +1 this also worked for me, thank you!!!!

thanks @Ivoz, your idea solved my problem.

thankyou @Ivoz It worked great!

@selectee4all Your solution works for me. "setenv all_proxy https://proxy_here:port_here/"
solves the proxy problem for not only this setup but for all installations. Thanks a lot.

I'm not sure how you can possibly have a virtualenv which emits 14.0.6. for its version but has bad old wheels in dist-packages/virtualenv_support. I would suggest removing all virtualenv* things in /usr/local/lib/python2.7/dist-packages/ and reinstalling it.

Thank you so much. This helped me!

Was this page helpful?
0 / 5 - 0 ratings