Generated wrapper scripts fail when Python executable path contains spaces

Issue #104 resolved
Paul Moore
created an issue

See This is a priority issue, as it means that the wrapper pip.exe executable generated by pip 10 won't work for a Python installation in a directory containing a space (e.g. C:\Program Files)

To reproduce, create a virtualenv with a space in the name. I'm here using the copy of distlib vendored with pip 10 (which is distlib 0.2.6), as that's where the bug was first reported.

The file "" below simply contains

def f():
    print("Hello from", __file__)

To reproduce the issue:

PS 13:30 {19:29.901} E:\Work\Scratch\a b                                                               
Python 3.6.2 (v3.6.2:5fd33b5, Jul  8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32              
Type "help", "copyright", "credits" or "license" for more information.                                 
>>> import sys                                                                                         
>>> sys.path.append(r'E:\Work\Projects\pip\src\pip\_vendor')                                           
>>> from distlib import scripts                                                                        
>>> s = scripts.ScriptMaker(r'E:\Work\Scratch\a b\x', r'E:\Work\Scratch\a b', add_launchers=True)      
>>> s.make('a=a:f')                                                                                    
['E:\\Work\\Scratch\\a b\\a.exe', 'E:\\Work\\Scratch\\a b\\a-3.6.exe']                                 

This creates a.exe, which when run, gives an error as follows:

>& 'E:\Work\Scratch\a b\a.exe'
Fatal error in launcher: Unable to create process using '""e:\work\scratch\a b\scripts\python.exe"  "E:\Work\Scratch\a b\a.exe" '

Comments (17)

  1. Atsushi Odagiri

    os windows10 64bit python 3.5.3 32bit

    I removed double quotes from that shebang, and ran that executable. That looks fine.

    • before #!"d:\aodag\works\python\pip space\venv\scripts\python.exe"
    • after #!d:\aodag\works\python\pip space\venv\scripts\python.exe
  2. Vinay Sajip

    I just saw this issue. Will cut a release as soon as I can. I won't actually merge the PR (since the actual sources which build the executable are in a separate upstream project - I'll fix it there) and then fixup distlib with the updated launchers.

  3. Vinay Sajip

    Aaargh. A recent Windows update seems to have borked my Visual Studio installation - it now complains that it can't find .NET Framework v4.0 (no idea why that's needed in a C/C++ project). Working on it...

  4. Vinay Sajip

    I've rebuilt and updated the launchers. Please try the distlib from changeset 7f9d6a9 and report back if replacing the pip-vendored version with it solves the problem. If it does solve the problem, I can cut a release.

  5. Takayuki Shimizukawa

    Thanks! It worked on my environment.

    • Win10 1803 Pro 64bit
    • Pytho-3.6.2 (32bit)
    • pip-10.0.0
    • virtualenv under C:\Users\taka\実験 D\virtualenv-pip10
    • replace C:\Users\taka\実験 D\virtualenv-pip10\Lib\site-packages\pip\_vendor\distlib with changeset 7f9d6a9
  6. Paul Moore reporter

    Confirmed that my original reproduction script now works. I also tested use from within pip, and that too seems to work now. So I think this is sufficient for a release.

  7. Log in to comment