Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
191 views
in Technique[技术] by (71.8m points)

Installing pip is not working in python < 3.6

I am starting to make a app using bitbucket CI and i am using the following steps to deploy the application and the steps to install pip is failing.

 script:
    - apt-get update
    - apt-get install -y python-dev
    - curl -O https://bootstrap.pypa.io/get-pip.py
    - python get-pip.py
    ... and a few more steps

Dont know why but python get-pip.py step fails with the following error.

Traceback (most recent call last):
  File "get-pip.py", line 24226, in <module>
    main()
  File "get-pip.py", line 199, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "/tmp/tmpUgc5ng/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^

SyntaxError: invalid syntax

This worked fine upto yesterday. Not sure why this is not working now.

I thought it may be because of windows but i checked in my local machine running linux but these steps but they worked fine.

question from:https://stackoverflow.com/questions/65869296/installing-pip-is-not-working-in-python-3-6

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

pip 21.0 dropped support for Python 2 and 3.5. The later versions require Python 3.6+. The syntax f"" is supported by Python 3.6+.

To install pip for Python 2.7 install it from https://bootstrap.pypa.io/2.7/ :

- curl -O https://bootstrap.pypa.io/2.7/get-pip.py
- python get-pip.py
- python -m pip install --upgrade "pip < 21.0"

The last command is to upgrade to the latest supported version. For Python 2.7 the latest supported is currently pip 20.3.4.

For Python 3.4 install from https://bootstrap.pypa.io/3.4/ . For Python 3.5 — https://bootstrap.pypa.io/3.5/ .

For Python 3.4 the upgrade command is

- python -m pip install --upgrade "pip < 19.2"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...