4

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.

Anjana Shivangi
  • 397
  • 2
  • 5
  • 19

1 Answers1

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.

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.

JHS
  • 1,423
  • 17
  • 29
  • Thank you! I could get curl working, but in my virtual environment I'm unable to run `pip install requests pex` , gives me the similar error. Why would that be happening? – Anjana Shivangi Apr 26 '18 at 15:57
  • No problem. @AnjanaShivangi That sounds like it could be another issue? You may have to open a separate question with the command, versions you're using or installing, and the error you're getting. It's possible that the latest versions of those packages have a `setup.py` or other code that's not compatible with Python 2.6. Please also mark the answer as accepted if it worked for your original issue :) – JHS Apr 26 '18 at 18:56