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

virtualenv doesn't install pip to ENV/bin #769

Closed
xuchen opened this issue Jun 8, 2015 · 7 comments
Closed

virtualenv doesn't install pip to ENV/bin #769

xuchen opened this issue Jun 8, 2015 · 7 comments

Comments

@xuchen
Copy link

xuchen commented Jun 8, 2015

The following error is what I have been struggling with:

xuchen@Xuchens-MacBook-Pro:/tmp$ which pip
/Users/xuchen/bin/pip

xuchen@Xuchens-MacBook-Pro:/tmp$ cat ~/bin/pip
#!/usr/local/bin/python    ---> Note the shebang here

# -*- coding: utf-8 -*-
import re
import sys

from pip import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

xuchen@Xuchens-MacBook-Pro:/tmp$ virtualenv test
New python executable in test/bin/python2.7
Also creating executable in test/bin/python
Please make sure you remove any previous custom paths from your /Users/xuchen/.pydistutils.cfg file.
Installing setuptools, pip, wheel...done.

xuchen@Xuchens-MacBook-Pro:/tmp$ pip
Traceback (most recent call last):
  File "/Users/xuchen/bin/pip", line 7, in <module>
    from pip import main
ImportError: No module named pip

xuchen@Xuchens-MacBook-Pro:/tmp$ ls test/bin/
activate  activate.csh  activate.fish  activate_this.py  python  python2  python2.7

xuchen@Xuchens-MacBook-Pro:/tmp$ head -n 1 ~/bin/pip
#!/private/tmp/test/bin/python2.7    ---> Note that shebang was changed

virtualenv changes the "shebang" of my pip file, and even after "deactivate", it doesn't change back, thus damaging my pip file. I couldn't find any pip installed under ENV/bin. This also breaks my tox testing procedure.

Update with versions: pip (7.0.1) and virtualenv (13.0.3)

@xuchen
Copy link
Author

xuchen commented Jun 9, 2015

looks like the root of problem is here:

http://stackoverflow.com/questions/24257803/distutilsoptionerror-must-supply-either-home-or-prefix-exec-prefix-not-both

But there's not an obvious solution...

@jgosmann
Copy link

It seems that virtualenv breaks when you have a ~/.pydistutils.cfg file which specifies an install prefix like

[install]
prefix=$HOME/bin

This can be a very hard problem to track down.

@xuchen
Copy link
Author

xuchen commented Jan 15, 2016

any workaround? If I remove that file, then pip install won't work...

@jgosmann
Copy link

pip install should still work in the virtualenv, outside of the virtualenv you can try pip install --user

Despite the workaround, it would be nice if virtualenv would detect and warn about this issue or handle it properly.

@GreenGremlin
Copy link

It looks like brewed Python installs ~/.pydistutils.cfg by default. This is an issue for anyone who installs Python on a Mac via Homebrew.

https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Homebrew-and-Python.md#note-on-pip-install---user

@xuchen
Copy link
Author

xuchen commented Jan 18, 2016

Nice catch, to summarize:

because of a bug in distutils, brewed Python disables pip install --user and instead writes ~/.distutils.cfg for a workaround, but this breaks virtualenv's pip.

How should this be fixed? Not counting on distutils ....

@stale
Copy link

stale bot commented Jan 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 14, 2019
@stale stale bot closed this as completed Jan 22, 2019
@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

3 participants