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

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


当前回答

Python -m PIP

在启动程序中出现致命错误:无法使用“”创建进程。在Windows 10上工作

其他回答

当virtualenv路径中有空格时,这是一个已知的错误。更正已做,并将提供在下一个版本。

当我重新安装python时,通过卸载python3.7和安装python3.8,我也有类似的问题。但是我通过删除以前版本的python目录解决了这个问题。对我来说,它位于这里,

C:\Users\your-username\AppData\Local\Programs\Python

我删除了名为Python37的文件夹(用于以前的版本),并保留Python38(用于更新版本)。这是因为python本身似乎在为你的python脚本找到正确的目录时遇到了麻烦。

我写了一个脚本补丁那些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:])

以下是我的解决方法:

在7zip文件中打开pip.exe,并将__main__.py解压到Python\Scripts文件夹中。 对我来说,是C:\Program Files (x86)\Python27\Scripts 将__main__.py重命名为pip.py 运行它!Python pip.py安装东西

编辑:

如果你想在任何地方安装一些东西,也可以这样做:

重命名PIP .py为pip2.py(以避免导入PIP错误) 制作C:\Program Files (x86)\Python27\pip.bat,内容如下:

C:\Program Files (x86)\Python27\Scripts\pip2.py" %1 %2 %3 %4 . python %5 %6 %7 %8 %9

将C:\Program Files (x86)\Python27添加到您的PATH(如果还没有) 运行它!PIP安装

我也有类似的问题,升级pip为我解决了这个问题。

python -m pip install --upgrade pip 

这是在Windows上,pip.exe内的python路径不正确。有关路径的更多信息,请参阅Archimedix答案。