卷曲的get-pip.py不起作用:语法错误 [英] curl for get-pip.py does not work: Syntax Error

查看:109
本文介绍了卷曲的get-pip.py不起作用:语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行时:

  [root @ pex Appliance_ui]#curl https://bootstrap.pypa.io./get-pip.py |Python 

它返回:

 %总计%接收的%Xferd平均速度时间时间时间当前电流Dload上传总花费左手速度100 1603k 100 1603k 0 0 7006k 0-:-:--:-:--:-:-13.2M追溯(最近一次通话):在< module>中的文件< stdin>",第20649行.在主文件中的文件< stdin>",第197行引导程序中的文件< stdin>",第82行< module>中的文件"/tmp/tmpH39pcu/pip.zip/pip/_internal/__init__.py",第42行.< module>中的文件"/tmp/tmpH39pcu/pip.zip/pip/_internal/cmdoptions.py",第16行.文件"/tmp/tmpH39pcu/pip.zip/pip/_internal/index.py",第526行{在all_candidates中为c的str(c.version)},^SyntaxError:语法无效 

  [root @ pex Appliance_ui]#python get-pip.py --verbose 

输出:

  python:无法打开文件'get-pip.py':[Errno 2]没有这样的文件或目录 

有人可以告诉我为什么会这样吗?我有Python 2.6和pip 9.0.1.我的目标是在整个项目中尽快升级到python 3.5.

解决方案

python 中找到的您使用的Python版本不支持集合理解.我可以看到在Python 2.4中尝试对[1,2,3]中的c执行 {str('foo')}的相同错误,而不是在2.7中起作用.

根据答案此处 https://bootstrap.pypa.io/2.6/get-pip.py

您还可以看到Python 2.7是此处列出的最受支持的版本:

Also,

[root@pex appliance_ui]# python get-pip.py --verbose

Output:

python: can't open file 'get-pip.py': [Errno 2] No such file or directory

Can anyone tell me why is this happening? I have Python 2.6 and pip 9.0.1. My aim is to upgrade to python 3.5 soon on the whole project.

The version of Python you're using found at python doesn't support set comprehensions. I can see the same error trying to do {str('foo') for c in [1,2,3]} in Python 2.4 as opposed to 2.7 where it works.

Per the answer here and the note in this section of the pip installation documentation you should use this URL for get-pip.py on 2.6: https://bootstrap.pypa.io/2.6/get-pip.py

You can also see Python 2.7 is the oldest supported version listed here: https://pip.pypa.io/en/stable/installing/#python-and-os-compatibility

As for [Errno 2] No such file or directory, that's because curl puts the file contents on standard out, not on your file system. If you wanted to download the file you would use wget.

这篇关于卷曲的get-pip.py不起作用:语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆