搜索网络,这似乎是由Python安装路径中的空格引起的问题。
我如何让pip工作,而不必重新安装在一个没有空格的路径中的所有东西?
搜索网络,这似乎是由Python安装路径中的空格引起的问题。
我如何让pip工作,而不必重新安装在一个没有空格的路径中的所有东西?
当前回答
我在使用django rest框架和simplejwt时遇到了这个问题。我所要做的就是升级pip并重新安装软件包
其他回答
我有一个更简单的解决方案。使用@apple方式,但将main.py重命名为pip.py,然后将其放在python版本scripts文件夹中,并将scripts文件夹添加到您的路径中,全局访问它。如果你不想把它添加到路径,你必须CD到脚本,然后运行PIP命令。
在Windows上,我用以下方法解决了这个问题:
1)卸载Python
2)导航到C:\Users\MyName\AppData\Local\Programs(您应该打开隐藏文件可见性显示隐藏文件指令)
3)删除“Python”文件夹
4)安装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:])
我将python.exe的可执行文件重命名为例如python27.exe。关于Archimedix的答案,我用十六进制编辑器打开我的pip.exe,滚动到文件的末尾,并将路径中的python.exe更改为python27.exe。在编辑make shure时,不重写其他信息。
当我重新安装python时,通过卸载python3.7和安装python3.8,我也有类似的问题。但是我通过删除以前版本的python目录解决了这个问题。对我来说,它位于这里,
C:\Users\your-username\AppData\Local\Programs\Python
我删除了名为Python37的文件夹(用于以前的版本),并保留Python38(用于更新版本)。这是因为python本身似乎在为你的python脚本找到正确的目录时遇到了麻烦。