搜索网络,这似乎是由Python安装路径中的空格引起的问题。

我如何让pip工作,而不必重新安装在一个没有空格的路径中的所有东西?


当前回答

我写了一个脚本补丁那些exe。但最好的办法是修复distutil本身。

"""Fix "Fatal error in launcher: Unable to create process using ..." error. Put me besides those EXE made by pip. (They are made by distutils, and used by pip)"""
import re
import sys
import os
from glob import glob


script_path = os.path.dirname(os.path.realpath(__file__))
real_int_path = sys.executable
_t = script_path.rpartition(os.sep)[0] + os.sep + 'python.exe'
if script_path.lower().endswith('scripts') and os.path.isfile(_t):
    real_int_path = _t

print('real interpreter path: ' + real_int_path)
print()

for i in glob('*.exe'):
    with open(i, 'rb+') as f:
        img = f.read()
        match = re.search(rb'#![a-zA-Z]:\\.+\.exe', img)
        if not match:
            print("can't fix file: " + i)
            continue
        int_path = match.group()[2:].decode()
        int_path_start = match.start() + 2
        int_path_end = match.end()

        if int_path.lower() == real_int_path.lower():
            continue
        print('fix interpreter path: %s in %s' % (int_path, i))
        f.seek(int_path_start)
        f.write(real_int_path.encode())
        f.write(img[int_path_end:])

其他回答

我试图安装一些站点包,如numpy, xgboost等,但每次都出现这个错误:

Fatal error in launcher: Unable to create process using

我尝试了很多方法来解决这个问题,并找到了这个方法,它成功地帮助了我:

python -m pip freeze

希望它也能帮助到别人。

附:我在这里找到了这个解决方案:https://stackoverflow.com/a/39733705/10310794

在Windows上,我用以下方法解决了这个问题:

1)卸载Python

2)导航到C:\Users\MyName\AppData\Local\Programs(您应该打开隐藏文件可见性显示隐藏文件指令)

3)删除“Python”文件夹

4)安装Python

如果您在Windows上使用区分大小写的文件系统,就会发生这种情况。如果你的venv目录中同时存在lib目录和lib目录,你就可以判断是否存在这种情况:

> dir

Directory: C:\git\case\sensitive\filesystem\here\venv

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----        4/07/2018   4:10 PM                Include
d-----       22/01/2019   7:52 AM                Lib
d-----       22/01/2019   7:52 AM                lib
d-----       22/01/2019   7:52 AM                Scripts
d-----       22/01/2019   7:52 AM                tcl

为了解决这个问题(直到virtualenv.py得到修复:https://github.com/pypa/virtualenv/issues/935)合并两个lib目录并使venv不区分大小写:

cd venv
move Lib rmthis
move .\rmthis\site-packages\ lib
rmdir rmthis
fsutil.exe file setCaseSensitiveInfo . disable

我写了一个脚本补丁那些exe。但最好的办法是修复distutil本身。

"""Fix "Fatal error in launcher: Unable to create process using ..." error. Put me besides those EXE made by pip. (They are made by distutils, and used by pip)"""
import re
import sys
import os
from glob import glob


script_path = os.path.dirname(os.path.realpath(__file__))
real_int_path = sys.executable
_t = script_path.rpartition(os.sep)[0] + os.sep + 'python.exe'
if script_path.lower().endswith('scripts') and os.path.isfile(_t):
    real_int_path = _t

print('real interpreter path: ' + real_int_path)
print()

for i in glob('*.exe'):
    with open(i, 'rb+') as f:
        img = f.read()
        match = re.search(rb'#![a-zA-Z]:\\.+\.exe', img)
        if not match:
            print("can't fix file: " + i)
            continue
        int_path = match.group()[2:].decode()
        int_path_start = match.start() + 2
        int_path_end = match.end()

        if int_path.lower() == real_int_path.lower():
            continue
        print('fix interpreter path: %s in %s' % (int_path, i))
        f.seek(int_path_start)
        f.write(real_int_path.encode())
        f.write(img[int_path_end:])

我有这个问题,这个页面上的其他修复并没有完全解决这个问题。

解决问题的方法是进入我的系统环境变量并查看PATH -我已经卸载了Python 3,但Python 3文件夹的旧路径仍然在那里。我在我的PC上只运行Python 2,并使用Python 2安装pip。

从PATH中删除对不存在的Python 3文件夹的引用,并升级到pip的最新版本,解决了这个问题。