I am trying to use these steps with bitbucket CI to deploy an application:
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
However, the python get-pip.py
step fails with this 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
Why isn’t it working now? Does it depend on the operating system?
For the equivalent issue with upgrading pip
in old Python installations, see Upgrading pip fails with syntax error caused by sys.stderr.write(f”ERROR: {exc}”).
Advertisement
Answer
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/pip/2.7/ :
- curl -O https://bootstrap.pypa.io/pip/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.6 install from https://bootstrap.pypa.io/pip/3.6/
- For Python 3.5 install from https://bootstrap.pypa.io/pip/3.5/
- For Python 3.4 install from https://bootstrap.pypa.io/pip/3.4/
- For Python 3.4 the upgrade command is
python -m pip install --upgrade "pip < 19.2"