-
Notifications
You must be signed in to change notification settings - Fork 3k
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
pip does not support spaces in directories names #923
Comments
Looks like a problem with not quoting the path to the interpreter in the #! line in pip-script.py. I can't reproduce on Windows because there is special code in virtualenv.py to use the "short name" which never has spaces. First question would be, how should a #! line be written in Unix to handle an interpreter with spaces in the pathname? The #! processing is at such a low level that I wouldn't want to assume that quoting the filename simply works on all platforms without verification... |
Sorry - should have mentioned, it's a virtualenv issue I'm talking about. |
I think you can simply escape it with "" Notice that the python produced by virtualenv is a binary, and that binary alone produces the error. So yeah, definitely a virtualenv issue |
Hmm, the python executable is simply copied/linked from the system one. Could this be a Python issue? What happens if you install Python into a directory with spaces in it? Note that the general rule is that Python doesn't like directories with spaces (that's one reason it's not installed in "Program Files" on Windows). I don't know if Python is expected to work when installed in a directory with spaces on OSX. I don't have access to OSX, so I won't be able to put together or test a patch for this. Sorry. |
I just got bit by this. Unfortunately, quoting in spaces nor escaping with backslashes fixes the problem. I am incredibly dismayed to find that OS X does not support a shebang with spaces in the interpreter path! Gah! I had to come up with an incredibly lame hack: cd virtualenv/bin I then populated pip with the following: #!/bin/bash "/Users/jpepas/Developer/Peepcode/Meet Jquery/flask/virtualenv/bin/python" "/Users/jpepas/Developer/Peepcode/Meet Jquery/flask/virtualenv/bin/.real_pip" $@ So the only bullet-proof workaround I see is for each of the scripts which use a shebang (for my setup, that's pip, pip-2.7, easy_install, easy_install-2.7) to be replaced by this level-of-indirection hack. I feel dirty now. (update 2017/5/28: just to be clear, my dismay is directed at Apple, this isn't the virtualenv team's fault.) |
Just encountered this problem on Mountain Lion 10.8.5, feels very strange. |
Spent time fixing my bash scripts (quoting and escaping those damn paths) only to find out the pip/virtualenv tooling doesn't support spaces ... 😞 |
It's not pip/virtualenv that doesn't support spaces. It's fundamentally an issue of the shebang feature provided by *nixes. You just can't have a space in your interpreter path for the shebang line. https://lists.gnu.org/archive/html/bug-bash/2008-05/msg00052.html I found this workaround, I'm not sure if it would be universally applicable without creating any regressions though
Then the python in |
It's not just a problem with spaces in shebang lines. For example, if you try and |
Is that a quoting failure on pip's or setuptool's part? |
Not sure - it might even be a bug in |
For folks looking for a simpler solution, I got #923 (comment) to work pretty well, in a simpler mode. I only ever needed to call pip once (during an install script), so instead of saying virtualenv .env
.env/bin/activate
pip install -r requirements.txt I did virtualenv .env
.env/bin/activate
python .env/bin/pip install -r requirements.txt Solved my my problem - still a challenge to call pip outside of the script, but the incision is more narrow. |
@AlexeyMK Thank you for posting that! It worked like a charm |
Just ran into this with pip version 1.5.6.
Seems it used to quote these paths, since older scripts installed fine. Not exactly sure what changed or when. Edits:
Update: |
For the record: this is not limited to Unix, I encountered the same situation on Windows Server 2012 with (ancient) Python 2.6.6 and (current) pip 7.1.0 and setuptools 18.0.1. The generated
which I manually fixed by adding quotes:
|
I think this is related to #2783. I've been seeing a lot of problems on Windows |
Any word on whether this will ever be fixed? I spent 15 minutes trying to figure out why pip wouldn't run inside my virtual environment. first line of yet: |
I got @AlexeyMK's comment above to work, though what he did wasn't clear to me at first so I though I would rephrase it: The problem here is that spaces in Rather than running pip directly (which itself is just a python script), and having it try to call the correct python interpreter implicitly (which fails), you can instead run it explicitly by calling Summary:With you virtualenv activated run
|
@smoothmango Would another option be to run Seems to be one way the docs specify to run it: https://pip.pypa.io/en/stable/installing/#upgrading-pip |
@johnthagen yes, the So you can shorten |
@Ivoz's approach:
Does not work on Mac:
For those who are interested, see exec_shell_imgact() function in Mac's XNU kernel |
I had this problem on Windows 10 with Python 3.5. I installed a package that provides a binary script but every time I run it I was getting Inserting quotes around the path to python.exe in |
When time allows, so it might be sometime in early September. There are a couple of |
That works well. ^.^ FTR - I just ran the test-suite of pip after vendoring the latest I guess that means this would be shipping as a part of pip 10 -- adding to the milestone. :) |
I have this problem on Windows 7 and quoting the path in the shebang line does not help. I find it pretty shocking that in 2017 we still develop software that falls flat on its face when encountering a space. |
I find it pretty shocking that after decades of agony developers still use spaces in paths and expect it to work :) This is a long standing issue with many facets. The person who fixes it upstream will be revered and adored like no other, maybe something is happening already? |
Just to quote myself here...
|
But what is shipping as part of pip 10, and is it just for Mac users or will it support Windows also? |
I think the fix is for *nix systems, so Linux and Mac. I'm not sure about Windows; @pfmoore or @vsajip likely have a better idea about the state of the situation there than me.
I'll quote @vsajip here:
(apologies for being terse; I have a mild headache right now) |
If you want to help ensure that the next release solves your issue you should download and test the development version of pip from github, and report back here. |
I'm not really into Python and this just confirmed I don't want to be. It's taken 4 years to add support for a space, and only to some platforms. |
FWIW this was never an issue on Windows apparently. So, yeah, this would fix it for all platforms.
@vsajip ping! Any ETA on the next release of |
@vsajip Ping 2.0! We're planning to do a pip 10 release soon -- in like another month or two |
Some more issues came up, including ones that affect |
Awesome. :) Just wanted to drop a reminder. |
Thanks for the release @vsajip! This fix will be shipping as a part of pip 10. |
under Mac OS X 10.7
Or maybe that's virtualenv ?
The text was updated successfully, but these errors were encountered: