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

Using pip launcher on Windows when path contains spaces #1997

Closed
Drekin opened this issue Aug 28, 2014 · 17 comments
Closed

Using pip launcher on Windows when path contains spaces #1997

Drekin opened this issue Aug 28, 2014 · 17 comments
Labels
auto-locked Outdated issues that have been locked by automation OS: windows Windows specific type: bug A confirmed bug or unintended behavior

Comments

@Drekin
Copy link

Drekin commented Aug 28, 2014

There is a problem when trying to run pip.exe when the path of Python installation contain spaces. Some launcher code adds extra quotes, which results in incorrect path and results in fatal error in launcher. See for example http://stackoverflow.com/questions/24627525/fatal-error-in-launcher-unable-to-create-process-using-c-program-files-x86. I understand that this is probably issue of the code producing the launcher (there is the same problem with IPython launcher), but I'm not sure where to report it.

@alexpilotti
Copy link

Hi, I managed to solve the issue by removing the quotes in the "ScriptMaker" used to generate the exe launchers.
As an alternative using short paths works as well (Windows paths have always their 8.3 counterpart, e.g.: "C:\progra~1" for "C:\Program Files", as this avoids the need for quotes

The problem is that Python is not working well when reading paths with quotes in the "shebang" section of the exe launchers.

Here's the proof of concept:

import os
import sys

from pip._vendor.distlib import scripts

specs = 'nova = novaclient.shell:main' 

scripts_path = os.path.join(os.path.dirname(sys.executable), 'Scripts')
m = scripts.ScriptMaker(None, scripts_path)

# This is e.g.: "C:\program Files\blah\blah\Python.exe"
m.executable = sys.executable
m.make(specs)

alexpilotti added a commit to alexpilotti/pip that referenced this issue Aug 28, 2014
Using spaces in Windows is common. This patch fixes an issue in the exe launch
wrappers generated in the "Scripts" directory where unnecessary quoting causes
the following error.

Fatal error in launcher: Unable to create process using '""C:\Program Files (x86)\Cloudbase    Solutions\OpenStack\Nova\Python27\python.exe"" "C:\Program Files (x86)\Cloudbase Solutions\OpenStack\Nova\Python27\Scripts\nova.exe" '

Closes issue: pypa#1997
@pfmoore
Copy link
Member

pfmoore commented Aug 28, 2014

I have a feeling this was fixed recently in distlib, and vendored into pip. Could you check if the issue still exists with the development version of pip from github?

@alexpilotti
Copy link

Did some quick tests and it worked. Closing the pull request by now, I'll investigate further and reopen it in case.

Thanks!

@alexpilotti
Copy link

Did some further investigations, the issue was in the "t32.exe" launcher and has been fixed by this patch in distlib:

https://bitbucket.org/vinay.sajip/distlib/commits/e231db5d1b01ac941f660ae54d54477a753712f8?at=default

IMO the issue can be considered closed.

@hyiltiz
Copy link

hyiltiz commented May 31, 2015

Still experiencing the problem when my pip had no spaces:
$ pip install --upgrade spyder
Fatal error in launcher: Unable to create process using '"C:\Python34\python.exe" "c:\Python34\Scripts\pip.exe" install --upgrade spyder'

@laike9m
Copy link

laike9m commented Oct 17, 2015

Comfirmed this on Windows 7 with Python 3.5.

My pip is in C:\Python3\Scripts\, no space.

@Ivoz
Copy link
Contributor

Ivoz commented Oct 17, 2015

@laike9m could you describe the exact error you're getting?

@laike9m
Copy link

laike9m commented Oct 17, 2015

C:\Users\dell>pip freeze
Fatal error in launcher: Unable to create process using '“‘

@xavfernandez xavfernandez added OS: windows Windows specific type: bug A confirmed bug or unintended behavior labels Oct 21, 2015
@DustinHolden
Copy link

Confirmed for Windows 10 as well. No spaces.

I am running it within a virtual environment, but that shouldn't be an issue.

Fatal error in launcher: Unable to create process using '"'

@lcetinsoy
Copy link

Same here and no virtual environment, windows 8.1
Both with python 3.5 and python 3.4 annaconda based distribution.

[edit] my path was polluted by a python version which was not properly uninstalled. It works with pyton3.4 anaconda

@YSunLIN
Copy link

YSunLIN commented Nov 1, 2015

pip PIP_FIND_LINKS env variable dosen't support the windows space, and it resulted in a virtualenv bugs. Because virtualenv can't install setuptools, wheel through the pip installed in C:/Program files/Python27 when I create an virtual evironment.

I think pip should support the double " , like windows cmd, such as
"C:\Program files\python27" (" is in the string) when you parse the PIP_FIND_LINKS.

And use the space to split PIP_FIND_LINKS into different paths which is not a good choice.

@IAMIronmanSam
Copy link

Just found this workaround http://stackoverflow.com/a/26428562/670565 hope it will be useful to someone 👍

@Drekin
Copy link
Author

Drekin commented Nov 13, 2015

It's not only workaround. Sometimes it's preferred to call pip using py -m pip, e.g. you can easily specify which version of Python installed you want to handle.

@Tset-Noitamotua
Copy link

Tset-Noitamotua commented Aug 6, 2016

Same shiat here when installing python with chocolatey.

Here's output in cmder after choco install python:

C:\Users\My Name
λ python --version
Python 3.5.1

C:\Users\My Name
λ pip --version
Fatal error in launcher: Unable to create process using '"'

C:\Users\My Name
λ which pip
/c/Users/My Name/AppData/Local/Programs/Python/Python35-32/Scripts/pip

A workaround for this issue is overriding --installargs (short -ia):
choco install python3 -y -o -ia "/quiet InstallAllUsers=1 TargetDir=c:\Python35"

@jsoref
Copy link

jsoref commented Aug 15, 2016

Windows 10, x86. I also have Python 3.5.1 (local user install, username does not have spaces in path), it had pip 7.1.2, which had this problem.
Running: python -m pip install -U pip
resulted in pip 8.1.2 being installed, which doesn't have this problem.

Once I upgraded to pip 8.1.2, I was able to run:
pip install --upgrade spyder without issue (it installed 2.3.9).

This issue's summary is pretty vague (it's missing "what's wrong"), the long description points to a stackoverflow question with a bunch of things. I'd suggest a maintainer clarify this issue summary to be limited to a single problem. If that problem is pip 7.1.2 and below yielding:
Fatal error in launcher: Unable to create process using '"' when people try to run pip, then this issue should be resolved as fixed. If it's something else, then at least people will know it isn't that issue (which is fixed...).

@dstufft
Copy link
Member

dstufft commented Mar 30, 2017

Closing this, I can't reproduce this. If you're still having issues please open a new issue with reproduction steps. It appears this was fixed in distlib.

@dstufft dstufft closed this as completed Mar 30, 2017
@ecornely
Copy link

ecornely commented Jul 4, 2017

Steps to reproduce:

  • install python in %appdata%
  • don't use it for months
  • type pip --version

That's it reproduced

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation OS: windows Windows specific type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests