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

纵饮孤独 提交于 2021-01-27 12:01:49

问题


When I try to run:

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

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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/50045697/curl-for-get-pip-py-does-not-work-syntax-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!