Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create vrtualenv with 1.11 (when virtualenv installed by ez_install/setuptools) #524

Closed
s0undt3ch opened this issue Jan 3, 2014 · 48 comments
Milestone

Comments

@s0undt3ch
Copy link

# virtualenv /tmp/123
Overwriting /tmp/123/lib/python2.7/site.py with new content
New python executable in /tmp/123/bin/python
Installing setuptools, pip...
  Complete output from command /tmp/123/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/log.py", line 8, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 2696, in <module>
    def _dep_map(self):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 429, in __init__
    def get_resource_stream(manager, resource_name):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 443, in add_entry
    """Is the named resource a directory?  (like ``os.path.isdir()``)"""
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1722, in find_in_zip
    except AttributeError:
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1298, in has_metadata
    def test(nodelist):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1614, in _has
    def _parts(self,zip_path):
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1488, in _zipinfo_name
    "Can't perform this operation for loaders without 'get_data()'"
AssertionError: /usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/EGG-INFO/PKG-INFO is not a subpath of /usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 820, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 988, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 956, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 898, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /tmp/123/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1
# python -V
Python 2.7.3
# pip freeze
Cheetah==2.4.4
GnuPGInterface==0.3.2
Jinja2==2.6
Landscape-Client==12.05
M2Crypto==0.21.1
MarkupSafe==0.15
PAM==0.4.2
PyYAML==3.10
SaltTesting==0.5.5
Twisted-Core==11.1.0
apache-libcloud==0.13.3
apt-xapian-index==0.44
argparse==1.2.1
boto==2.2.2
chardet==2.0.1
cloud-init==0.6.3
command-not-found==0.2.44
configobj==4.7.2
coverage==3.7.1
euca2ools==2.0.0
httplib2==0.7.2
keyring==0.9.2
language-selector==0.1
launchpadlib==1.9.12
lazr.restfulclient==0.12.0
lazr.uri==1.0.3
mock==1.0.1
msgpack-python==0.1.10
oauth==1.0.1
paramiko==1.7.7.1
pyOpenSSL==0.12
pycrypto==2.4.1
pycurl==7.19.0
pyserial==2.5
python-apt==0.8.3ubuntu7.1
python-debian==0.1.21ubuntu1
pyzmq==13.0.0
salt==2014.1.0-31-g0998b54
simplejson==2.3.2
timelib==0.2.4
ufw==0.31.1-1
unattended-upgrades==0.1
unittest-xml-reporting==1.7.0
virtualenv==1.11
wadllib==1.3.0
wsgiref==0.1.2
zope.interface==3.6.1

Is there any more info that I can provide?

@pg1671
Copy link

pg1671 commented Jan 4, 2014

+1

@ionelmc
Copy link

ionelmc commented Jan 4, 2014

Same issue here

virtualenv .ve --python=/usr/bin/python2.7 --system-site-packages
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in .ve/bin/python2.7
Also creating executable in .ve/bin/python
Installing setuptools, pip...
  Complete output from command /home/nestea/deploye...f6/.ve/bin/python2.7 -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
    # See the README file for information on usage and redistribution.
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/log.py", line 8, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 2696, in <module>
    # Prepare the master working set and make the ``require()`` API available
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 429, in __init__
    self.callbacks = []
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 443, in add_entry
    always appended to ``.entries``, even if it is already present.
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1722, in find_in_zip
    """Yield distributions accessible on a sys.path directory"""
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1298, in has_metadata

  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1614, in _has

  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/pkg_resources.py", line 1488, in _zipinfo_name

AssertionError: /usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/EGG-INFO/PKG-INFO is not a subpath of /usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/setuptools-2.0.2-py2.py3-none-any.whl/

@xen
Copy link

xen commented Jan 4, 2014

I have different problem with the same virtualenv version. Instead of traceback I'm getting Could not find an activated virtualenv (required). and site-packages folder is empty after execution of $ virtualenv-2.7 --system-site-packages venv. The same time under py3.3 everything works. Sorry, python 3 version was outdated, the same error.

@qwcode
Copy link

qwcode commented Jan 4, 2014

marking for 1.11.1

@qwcode
Copy link

qwcode commented Jan 4, 2014

I can replicate this. this occurs when virtualenv is installed with easy_install (or "python setup.py install")

cc @pfmoore

@qwcode
Copy link

qwcode commented Jan 4, 2014

this is related to the zip imports that are now occurring.
given that the exception occurs after pip tries to import pkg_resources, it might be that we fix this simply by doing pypa/pip#1422

@pfmoore
Copy link
Member

pfmoore commented Jan 4, 2014

Yep, I see it too. Looks like a setuptools bug - the assertion error occurs in pkg_resources and it looks like it's because we have a zipfile on sys.path (i.e., we're using zipimport) where the zipfile is inside a setuptools "unpacked egg" format package, Beyond that, I don't know - I don't know why pkg_resources is making this check.

Maybe @jaraco can comment?

@pfmoore
Copy link
Member

pfmoore commented Jan 4, 2014

Not sure that pypa/pip#1422 will help - we'll still be using pkg_resources, just a vendored copy.

@qwcode
Copy link

qwcode commented Jan 4, 2014

better to fix the setuptools bug, but one thought if pip is independent of setuptools, is to not add the wheels to pythonpath (which leads to the zip pkg_resources failures) but rather to make the the pip wheel executable (not exactly sure how that works), and use it as such in the virtualenv creation

@qwcode
Copy link

qwcode commented Jan 4, 2014

@pfmoore
Copy link
Member

pfmoore commented Jan 4, 2014

better to fix the setuptools bug, but one thought if pip is independent of
setuptools, is to not add the wheels to pythonpath (which leads to the zip
pkg_resources failures) but rather to make the the pip wheel executable
(not exactly sure how that works), and use it as such in the virtualenv
creation

That might work. And it might also be a useful feature anyway - to have a
one-file standalone pip that can be run without installing.

@flyte
Copy link

flyte commented Jan 6, 2014

Is this the same issue as I'm having? Virtualenv works when installed with pip but not with easy_install. I have a different stacktrace to the OP though.

The ones using ez_setup.py have these versions:

pip 1.5 from /usr/local/lib/python2.7/dist-packages/pip-1.5-py2.7.egg (python 2.7)
setuptools 2.0.2
virtualenv 1.11

whereas the ones using distribute_setup.py have

pip 1.5 from /usr/local/lib/python2.7/dist-packages/pip-1.5-py2.7.egg (python 2.7)
distribute 0.6.49
virtualenv 1.11

The following are all done on a clean vagrant 'precise64' Ubuntu box.

WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo python
sudo easy_install pip
sudo pip install virtualenv
virtualenv ve

WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl http://python-distribute.org/distribute_setup.py | sudo python
sudo easy_install pip
sudo pip install virtualenv
virtualenv ve

WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo python
sudo easy_install pip
sudo easy_install virtualenv
virtualenv ve # Doesn't work
sudo pip uninstall virtualenv
sudo pip install virtualenv
rm -rf ve
virtualenv ve

WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl http://python-distribute.org/distribute_setup.py | sudo python
sudo easy_install pip
sudo easy_install virtualenv
virtualenv ve # Doesn't work
sudo pip uninstall virtualenv
sudo pip install virtualenv
rm -rf ve
virtualenv ve

NOT WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo python
sudo easy_install virtualenv
virtualenv ve

NOT WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py | sudo python
sudo easy_install pip
sudo easy_install virtualenv
virtualenv ve

NOT WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl http://python-distribute.org/distribute_setup.py | sudo python
sudo easy_install virtualenv
virtualenv ve

NOT WORKING:

sudo apt-get update && sudo apt-get install -y curl && curl http://python-distribute.org/distribute_setup.py | sudo python
sudo easy_install pip
sudo easy_install virtualenv
virtualenv ve

The NOT WORKING ones all produce this output:

vagrant@precise64:~$ virtualenv ve
New python executable in ve/bin/python
Installing setuptools, pip...
  Complete output from command /home/vagrant/ve/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv_support/pip-1.5-py2.py3-none-any.whl/pip/log.py", line 8, in <module>
ImportError: No module named pkg_resources
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/usr/local/bin/virtualenv", line 9, in <module>
    load_entry_point('virtualenv==1.11', 'console_scripts', 'virtualenv')()
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 820, in main
    symlink=options.symlink)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 988, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 956, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/usr/local/lib/python2.7/dist-packages/virtualenv-1.11-py2.7.egg/virtualenv.py", line 898, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/vagrant/ve/bin/python -c "import sys, pip; pip...ll\"] + sys.argv[1:])" setuptools pip failed with error code 1

@qwcode
Copy link

qwcode commented Jan 6, 2014

@pfmoore not sure if you're monitoring the setuptools issue, but that's fairly well understood now, and I opened a PR for discussion, if you care to make any comment.

https://bitbucket.org/pypa/setuptools/pull-request/32

the point being is that I don't think we have to rely on a pip-only solution to this

@pfmoore
Copy link
Member

pfmoore commented Jan 6, 2014

@qwcode yes, I saw your fix, looks OK to me (although I haven't actually tested it myself, as I can't do much more than apply the patch and try reproducing this issue, which I guess you've done).

I'd certainly much rather it get fixed in setuptools. If we get a new setuptools release, I assume we need to do a quick virtualenv release to bundle the updated setuptools. Not sure if ensurepip also needs updating.

@jaytaylor
Copy link

Reverting virtualenv to version 1.10.1 (instead of 1.11) fixes the issue.

See: http://stackoverflow.com/questions/20925329/trouble-with-creating-a-virtual-environment-in-windows-8-python-3-3/20959427#20959427

@qwcode
Copy link

qwcode commented Jan 7, 2014

@flyte likely the same issue, although I'm not sure why your trace reports differently with a pkg_resources ImportError

@jaytaylor yes, this bug is a compatibility issue with a new virtualenv-1.11 feature and setuptools.

@qwcode
Copy link

qwcode commented Jan 7, 2014

the setuptools PR for this (https://bitbucket.org/pypa/setuptools/pull-request/32) has been merged and will be released in setuptools 2.0.3

I've tested an easy_install'ed virtualenv, that included a tip-built setuptools (that has the fix), and it works.

leaving this open, until the 2.03 release, when we can bundle it into virtualenv_support.

@qwcode
Copy link

qwcode commented Jan 8, 2014

closing, as the fixed setuptools (v2.1) is now included in virtualenv_support in 1.11.X

@ionelmc
Copy link

ionelmc commented Jan 21, 2014

This still happens on 1.11.1 - I'm opening a different issue for this: #552

@prologic
Copy link

prologic commented Mar 5, 2014

This is still causing issues for me:

$ mkvirtualenv --system-site-packages ccav
Using real prefix '/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7'
New python executable in ccav/bin/python2.7
Openinig: /Users/s2092651/bin/python2.7
Opened: /Users/s2092651/bin/python2.7
Openining: ccav/bin/python2.7
Opened: /Users/s2092651/bin/python2.7
Also creating executable in ccav/bin/python
Openinig: /Users/s2092651/bin/python2.7
Opened: /Users/s2092651/bin/python2.7
Openining: ccav/bin/python
Opened: /Users/s2092651/bin/python2.7
Openinig: /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Opened: /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Openining: ccav/bin/python2.7
Opened: /usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Please make sure you remove any previous custom paths from your /Users/s2092651/.pydistutils.cfg file.
Installing setuptools, pip...
  Complete output from command /Users/s2092651/.vir...s/ccav/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip:
  Could not find an activated virtualenv (required).
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/Users/s2092651/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/Users/s2092651/lib/python2.7/site-packages/virtualenv.py", line 824, in main
    symlink=options.symlink)
  File "/Users/s2092651/lib/python2.7/site-packages/virtualenv.py", line 992, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/Users/s2092651/lib/python2.7/site-packages/virtualenv.py", line 960, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/Users/s2092651/lib/python2.7/site-packages/virtualenv.py", line 902, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/s2092651/.vir...s/ccav/bin/python2.7 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 3

Versions:

$ syspip freeze | egrep "(pip|virtualenv|setuptools)" && python -c "import pip; print pip.__version__; import setuptools; print setuptools.__version__"
pipdeptree==0.2
virtualenv==1.11.4
virtualenv-clone==0.2.4
virtualenvwrapper==4.2
1.5.4
2.2

@qwcode
Copy link

qwcode commented Mar 5, 2014

@therealprologic your error is different than the others above.

the error is "Could not find an activated virtualenv (required)"

I'm guessing you're setting PIP_REQUIRE_VIRTUALENV? and that's interfering with the pip install that virtualenv uses to install pip and setuptools (yes, virtualenv is using pip to install pip; it adds the pip wheel to the pythonpath, which is importable)

@pfmoore has this come up in an issue already? thinking we should specifically unset PIP_REQUIRE_VIRTUALENV

@prologic
Copy link

prologic commented Mar 5, 2014

On Wed, Mar 5, 2014 at 3:17 PM, Marcus Smith notifications@github.comwrote:

the error is "Could not find an activated virtualenv (required)"

I'm guessing you're setting PIP_REQUIRE_VIRTUALENV? and that's
interfering with the pip install that virtualenv uses to install pip and
setuptools (yes, virtualenv is using pip to install pip; it adds the pip
wheel to the pythonpath, which is importable)

No I'm not doing this at all.

Downgrading virtualenv to 1.10.0 got me back to a working virtualenv
again.

James Mills / prologic

E: prologic@shortcircuit.net.au
W: prologic.shortcircuit.net.au

@qwcode
Copy link

qwcode commented Mar 5, 2014

I scanned the vitualenvwrapper code but don't see it setting anything.
the fact remains that pip is returning "Could not find an activated virtualenv (required)", and it only does that if --require-virtualenv (or PIP_REQUIRE_VIRTUALENV) is set, and it's not in a virtualenv

@prologic
Copy link

prologic commented Mar 5, 2014

On Wed, Mar 5, 2014 at 3:27 PM, Marcus Smith notifications@github.comwrote:

I scanned the vitualenvwrapper code but don't see it setting anything.
the fact remains that pip is returning "Could not find an activated
virtualenv (required)", and it only does that if --require-virtualenv (or
PIP_REQUIRE_VIRTUALENV) is set, and it's not in a virtualenv

Problem is I'm not doing this anywhere.

James Mills / prologic

E: prologic@shortcircuit.net.au
W: prologic.shortcircuit.net.au

@qwcode
Copy link

qwcode commented Mar 5, 2014

Problem is I'm not doing this anywhere.

roger that. just saying that something is setting it. : )

@prologic
Copy link

prologic commented Mar 5, 2014

On Wed, Mar 5, 2014 at 3:35 PM, Marcus Smith notifications@github.comwrote:

roger that. just saying that something is setting it. : )

If you can think of anything else that might, I'm happy to check!

James Mills / prologic

E: prologic@shortcircuit.net.au
W: prologic.shortcircuit.net.au

@qwcode
Copy link

qwcode commented Mar 5, 2014

do you have any PIP_* env variables, or anything custom in pip.conf?

@prologic
Copy link

prologic commented Mar 5, 2014

On Wed, Mar 5, 2014 at 3:45 PM, Marcus Smith notifications@github.comwrote:

do you have any PIP_* env variables, or anything custom in pip.conf?

Ahh now we're talking!

See:

s2092651@031986
Wed Mar 05 15:46:14
~
$ export | grep PIP -i
declare -x PIP_DOWNLOAD_CACHE="/Users/s2092651/.pip/cache"
declare -x PIP_REQUIRE_VIRTUALENV="true"

s2092651@031986
Wed Mar 05 15:46:18
~
$ grin -i PIP .profile .profile.d

s2092651@031986
Wed Mar 05 15:46:50
~
$ cat .pip/pip.conf
[global]
;index-url = http://localhost:3141/root/pypi/+simple/
;index-url http://pypi.rcs.griffith.edu.au:3143/root/pypi/+simple/
;index-url = http://mirror.rcs.griffith.edu.au:3143/root/pypi/+simple/
;index-url = http://devpi.net/root/pypi/+simple/

So I have no idea where the PIP_* env vars are coming from.
Could they be coming from the fact that $HOME is also a virtualenv?

James Mills / prologic

E: prologic@shortcircuit.net.au
W: prologic.shortcircuit.net.au

@qwcode
Copy link

qwcode commented Mar 5, 2014

declare -x PIP_REQUIRE_VIRTUALENV="true"

that's it. you need to unset it before running your mkvirtualenv command.

Could they be coming from the fact that $HOME is also a virtualenv?

not PIP_REQUIRE_VIRTUALENV
looks like a shared server that's managed?

@prologic
Copy link

prologic commented Mar 5, 2014

Except that this is my work OS X desktop and I don't set any such env bars
anywhere!
On Mar 5, 2014 4:29 PM, "Marcus Smith" notifications@github.com wrote:

declare -x PIP_REQUIRE_VIRTUALENV="true"

that's it. you need to unset it before running your mkvirtualenv command.

Could they be coming from the fact that $HOME is also a virtualenv?

not PIP_REQUIRE_VIRTUALENV
looks like a shared server that's managed?


Reply to this email directly or view it on GitHubhttps://github.com//issues/524#issuecomment-36714135
.

@pfmoore
Copy link
Member

pfmoore commented Mar 5, 2014

@qwcode yeah, unsetting PIP_REQUIRE_VIRTUALENV is probably a good idea. Roll on isolated mode :-)

@imju
Copy link

imju commented May 3, 2014

Just FYI, the virtualenv 1.11.5 (Mar. 3 release) regressed with same issue. Downgraded to 1.11.2 solve the problem. Please check my question, https://stackoverflow.com/questions/23448796/creating-new-virtualenv-failed-with-setuptools-issue

carlio pushed a commit to akvo/akvo-provisioning that referenced this issue Jun 2, 2014
@rhythmer
Copy link

THX to all ,I fix my problem

@derekpng
Copy link

derekpng commented Dec 1, 2014

Hi Everyone, Not sure if this is the same issue, but I'm getting the following 'errors' when I try to use virtualenv (it also happens for version 1.10.1 and 1.11.6):

~/projects/python$ virtualenv --no-site-packages test
Using base prefix '/opt/local/Library/Frameworks/Python.framework/Versions/3.4'
New python executable in test/bin/python3.4
Also creating executable in test/bin/python
Installing setuptools, pip...
  Complete output from command /Users/derekng/Docum...n/test/bin/python3.4 -c "import sys, pip;     sys...d\"] + sys.argv[1:]))" setuptools pip:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/__init__.py", line 9, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/virtualenv_support/pip-1.5.6-py2.py3-none-any.whl/pip/log.py", line 6, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/logging/__init__.py", line 28, in <module>
    from string import Template
ImportError: cannot import name 'Template'
----------------------------------------
...Installing setuptools, pip...done.
Traceback (most recent call last):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/Current/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/virtualenv.py", line 824, in main
    symlink=options.symlink)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/virtualenv.py", line 992, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/virtualenv.py", line 960, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/virtualenv.py", line 902, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /Users/derekng/Docum...n/test/bin/python3.4 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip failed with error code 1

I'm using python 3.4.2 and pip 1.5.6. Both python and pip were installed using MacPorts, and virtualenv installed using pip. I'm on a mac (Yosemite).

Thanks

@Ivoz
Copy link

Ivoz commented Dec 1, 2014

That's extremely weird, Template should be a standard python library class.

@mdengler
Copy link

mdengler commented Dec 1, 2014

I've seen that type of ImportError when some package 'foo' is in sys.path ahead of the standard library package of the same name.

@gkoshyk
Copy link

gkoshyk commented Jul 30, 2015

Looks like a similar error, Please help!
$virtualenv venv

New python executable in venv/bin/python
Installing setuptools, pip, wheel...
Complete output from command /Users/george/D...ores/venv/bin/python -c "import sys, pip; sys...d"] + sys.argv[1:]))" setuptools pip wheel:
Traceback (most recent call last):
File "", line 1, in
File "/Users/george/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/init.py", line 13, in
File "/Users/george/anaconda/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/utils/init.py", line 15, in
File "/Users/george/anaconda/lib/python2.7/zipfile.py", line 6, in
import io
File "/Users/george/anaconda/lib/python2.7/io.py", line 51, in
import _io
ImportError: dlopen(/Users/george/Downloads/flaskApps/userScores/venv/lib/python2.7/lib-dynload/_io.so, 2): Symbol not found: __PyErr_ReplaceException
Referenced from: /Users/george/Downloads/flaskApps/userScores/venv/lib/python2.7/lib-dynload/_io.so
Expected in: dynamic lookup


...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "/Users/george/anaconda/bin/virtualenv", line 11, in
sys.exit(main())
File "/Users/george/anaconda/lib/python2.7/site-packages/virtualenv.py", line 832, in main
symlink=options.symlink)
File "/Users/george/anaconda/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
install_wheel(to_install, py_executable, search_dirs)
File "/Users/george/anaconda/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
'PIP_NO_INDEX': '1'
File "/Users/george/anaconda/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command /Users/george/D...ores/venv/bin/python -c "import sys, pip; sys...d"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1

@aaronlelevier
Copy link

I am having a similar error on Centos 7 with Python 3.3.

Has anyone been able to solve this??

Here's my command:

virtualenv -p /usr/local/bin/python3 ~/.virtualenvs/bs_py3

And Error:

[~]$ virtualenv -p /usr/local/bin/python3 ~/.virtualenvs/bs_py3
Running virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/usr/local'
New python executable in /home/vagrant/.virtualenvs/bs_py3/bin/python3
Not overwriting existing python script /home/vagrant/.virtualenvs/bs_py3/bin/python (you must use /home/vagrant/.virtualenvs/bs_py3/bin/python3)
Installing setuptools, pip, wheel...
  Complete output from command /home/vagrant/.virtualenvs/bs_py3/bin/python3 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
  Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/__init__.py", line 15, in <module>
  File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/vcs/subversion.py", line 9, in <module>
  File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/index.py", line 30, in <module>
  File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/wheel.py", line 35, in <module>
  File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 14, in <module>
  File "/usr/lib/python2.7/site-packages/virtualenv_support/pip-7.1.0-py2.py3-none-any.whl/pip/_vendor/distlib/compat.py", line 66, in <module>
ImportError: cannot import name HTTPSHandler
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 2363, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 832, in main
    symlink=options.symlink)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 1004, in create_environment
    install_wheel(to_install, py_executable, search_dirs)
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 969, in install_wheel
    'PIP_NO_INDEX': '1'
  File "/usr/lib/python2.7/site-packages/virtualenv.py", line 910, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /home/vagrant/.virtualenvs/bs_py3/bin/python3 -c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with error code 1

@ellockie
Copy link

I had a very similar issues on my Windows 7 machine. Both paths, to python and to my VE had spaces in it. Couple of months before it worked fine. I found the following note on virtualenv website:

Windows Notes
[...] To create a virtualenv under a path with spaces in it on Windows, you’ll need the win32api library installed.

The following steps lead me to success:

  1. Make sure I used pip to install virtualenv and it's the latest version (pip-7.1.0). Result: failure
  2. Install win32api. Result: failure (although there was some error at the very end of installation process).
  3. Try to install my VE in a path without spaces. Result: failure.
  4. Reinstall my Anaconda python distribution to the path that didn't contain the "[" and "]" brackets. VE had spaces in the path. Result: failure.
  5. Reinstall my Anaconda python distribution to the path that also didn't contain any spaces. VE had spaces in the path. Result: success!

So at least the Anaconda (python) installation simple, non space-pollutted path was crucial. Maybe win32api installation was also important. Not sure.

@jayinai
Copy link

jayinai commented Aug 25, 2015

@gkoshyk I have the exact same issue as you did. Did you solve it?

@dustinlakin
Copy link

I was recently getting this error on OS X 10.10.4. I ended up doing a fresh install of python (2.7.9) with brew, reopened my terminal and "virtualenv venv" worked fine.

@RoboGenius
Copy link

When I recently ran in to this problem within a Windows installation of Python 2.7.10 and the latest update for virtualenv and setuptools, I hit the internet and found nothing but "this is already fixed" messages from 2014. Thank you to @ellockie for suggesting the simple solution of making sure Python is installed in a path without any spaces. I uninstalled my current installation (c:\DevTools\Python 27), and reinstalled to a new directory (c:\DevTools\Python27) and it worked the first time. Cheers!

@gkoshyk
Copy link

gkoshyk commented Oct 26, 2015

@shuaiw I was not able to resolve it.

@downunder54
Copy link

I just did a "brew install python" on Yosemite followed by "virtualenv flaskapp" but it still conks out with "OSError: Command /Users/foo/src/python/flaskapp/bin/python -c "import sys, pip; sys...d"] + sys.argv[1:]))" setuptools pip failed with error code 1"
Any ideas anyone?

@downunder54
Copy link

on the pip install it mentions: "AttributeError: 'module' object has no attribute 'mac_ver'"

in: File "/Library/Python/2.7/site-packages/virtualenv_support/pip-6.0.8-py2.py3-none-any.whl/pip/_vendor/pkg_resources/init.py", line 352, in _macosx_vers

@Ivoz
Copy link

Ivoz commented Dec 26, 2015

Hi there, could all new comments with a similar problem please open a new issue instead of posting a comment. This issue is getting far too convoluted, and its hard to see if problems mentioned are all coming from the same source or have differences.

@shintojoseph1234
Copy link

This will work for virtualenv pip wheel errorcode1 problems and also E unable to locate package problems

apt-get update

apt-get install python-software-properties

apt-get install apt-file

apt-file update

apt-get install software-properties-common

apt-get install <your filename>  

@mohammedyunus009
Copy link

Even i was having the same problem with python virtualenv It got corrected by a simple restart

sudo shutdown -r now

@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests