search
LoginSignup
10
Help us understand the problem. What are the problem?

More than 3 years have passed since last update.

posted at

updated at

Python2 で get-pip.py で SyntaxError

pipのインストールに際して、Python2系だとSyntaxエラーが出るようです。
Pythonの新しいバージョンが入れられない場合は、以下のように対応できます。

環境

# cat /etc/redhat-release
CentOS release 6.9 (Final)
# python -V
Python 2.6.6

やりたかったこと

Linux に AWS Command Line Interface をインストールします
ここの
pip のインストール

現象

# python get-pip.py
Traceback (most recent call last):
  File "get-pip.py", line 20651, in <module>
    main()
  File "get-pip.py", line 197, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip._internal
  File "/tmp/tmp8OYExX/pip.zip/pip/_internal/__init__.py", line 42, in <module>
  File "/tmp/tmp8OYExX/pip.zip/pip/_internal/cmdoptions.py", line 16, in <module>
  File "/tmp/tmp8OYExX/pip.zip/pip/_internal/index.py", line 536
    {str(c.version) for c in all_candidates},
                      ^
SyntaxError: invalid syntax

解決策

$ curl -O https://bootstrap.pypa.io/get-pip.py
↓
$ curl -O https://bootstrap.pypa.io/2.6/get-pip.py

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
10
Help us understand the problem. What are the problem?