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

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


当前回答

我在Window中解决了我的问题 如果同时安装python2和python3

你需要输入某人\脚本将所有file.exe更改为file27.exe,然后它就解决了

我的D:\Python27\脚本编辑django-admin.exe到django-admin27.exe,这样就完成了

其他回答

我今天遇到了这个问题。我得到这个错误的原因是因为我有一个项目存储在Dropbox上,我从2台不同的电脑访问。

我正在使用venv,因为我在机器A上安装了venv,如果我试图在机器B上运行pytest,我会得到错误。

删除venv文件夹,运行python -m venv venv为我解决了这个问题。

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

至少在Windows上,pip在安装时将执行路径存储在可执行程序pip.exe中。

使用十六进制编辑器或写字板编辑这个文件(你必须将其保存为纯文本,然后保留二进制数据),用引号和空格将路径更改为Python,像这样:

#!"C:\Program Files (x86)\Python33\python.exe"

到一个转义路径,没有空格和引号,填充有空格(最后的点应该是空格):

#!C:\Progra~2\Python33\python.exe.............

对于“C:\Program Files”,这个路径可能是“C:\Progra~1”(DOS / Windows 3中的路径名称缩写)。X符号使用波浪号和数字)。 Windows为向后兼容DOS / Windows 3提供了这种替代表示法。x应用程序。

请注意,由于这是一个二进制文件,您不应该更改文件大小,这可能会破坏可执行文件,因此需要填充。

以管理员权限保存,确保它实际保存在目标位置,然后重试。

您可能还需要设置PATH变量,以便使用~符号表示pip的路径。

似乎

python -m pip install XXX 

无论如何都会工作(为我工作过) (参见user474491的链接)

这是我如何解决它。

下载https://bootstrap.pypa.io/get-pip.py 激活你的vitualenv 导航到get-pip.py文件,输入“python get-pip.py”,不带引号。

它将在环境中重新安装PIP,并自动卸载以前的版本。

现在繁荣! !安装你喜欢的任何东西