现象:error: subprocess-exited-with-error
背景:安装pyautogui报错
pip install pyautogui
Collecting pyautogui
Using cached PyAutoGUI-0.9.53.tar.gz (59 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [34 lines of output]
Traceback (most recent call last):
File "" , line 2, in
File "" , line 34, in
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
查了很多资料,先把系统相关资料给出:
windows11家庭中文版21H2,
python版本号3.9.13,无其他版本
pip版本22.2.2
setuptools版本65.1.0
尝试过的方法:升级pip,setuptools两个东西
但是更换下载源居然能够下载库,但是仍然会报错,报错内容一样
#使用其他源下载python有关资源
import os
yuan = {
"阿里云":"https://mirrors.aliyun.com/pypi/simple/",
"中国科技大学":"https://pypi.mirrors.ustc.edu.cn/simple/",
"豆瓣(douban)":"https://pypi.douban.com/simple/",
"清华大学":"https://pypi.tuna.tsinghua.edu.cn/simple/"
}
def main():
name = input("请输入目标名称:\n")
print("\n")
for i in yuan.items():
print(i)
xuan = int(input("\n\n请选择源:(数字)\n")) -1
ru = "pip install " + name +" -i " + list(yuan.values())[xuan]
a = os.popen(ru)
print(a.read())
print("使用其他源下载python有关资源,输入''以停止程序。")
while True:
main()
x = input()
if x == "":
break
else:
continue
这个是我自己写的,自由选择镜像源下载库
能够修复这个报错
后来运行程序发现,下载的库只是一个摆设,并没有实际功能,我发这个贴的目的不在于pyautogui,这个库本身没犯错,但是python自带的setuptools报错确实很烦
后面把python版本降成3.8.10之后一切都正常了