curl for get-pip.py does not work: Syntax Error

Anj*_*ngi 4 curl pip python-2.6 centos6 python-3.5

When I try to run:

[root@pex appliance_ui]# curl https://bootstrap.pypa.io./get-pip.py | python
Run Code Online (Sandbox Code Playgroud)

It returns:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1603k  100 1603k    0     0  7006k      0 --:--:-- --:--:-- --:--:-- 13.2M
Traceback (most recent call last):
  File "<stdin>", line 20649, in <module>
  File "<stdin>", line 197, in main
  File "<stdin>", line 82, in bootstrap
  File "/tmp/tmpH39pcu/pip.zip/pip/_internal/__init__.py", line 42, in <module>
  File "/tmp/tmpH39pcu/pip.zip/pip/_internal/cmdoptions.py", line 16, in <module>
  File "/tmp/tmpH39pcu/pip.zip/pip/_internal/index.py", line 526
    {str(c.version) for c in all_candidates},
                      ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

Also,

[root@pex appliance_ui]# python get-pip.py --verbose
Run Code Online (Sandbox Code Playgroud)

Output:

python: can't open file 'get-pip.py': [Errno 2] No such file or directory
Run Code Online (Sandbox Code Playgroud)

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.

JHS*_*JHS 5

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.

每答案在这里在PIP安装文档的这一部分的说明,你应该使用这个网址get-pip.py 2.6:https://bootstrap.pypa.io/2.6/get-pip.py

您还可以看到 Python 2.7 是此处列出的最旧的受支持版本:https : //pip.pypa.io/en/stable/installing/#python-and-os-compatibility

至于[Errno 2] No such file or directory,那是因为curl将文件内容放在标准输出上,而不是放在您的文件系统上。如果要下载文件,请使用wget.