0

When trying to use python3.5 in a virtual environment, I find some f-strings in pip's scripts, preventing me from installing anything through pip as f-strings were introduced in python3.6. I've run this in a number of configurations, but this is the simplest snippet that shows the problem:

user@machine:/path/to/project$ virtualenv -p $(which python3.5) ./venv
Running virtualenv with interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /path/to/project/venv/bin/python3.5
Also creating executable in /path/to/project/venv/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.
(venv) user@machine:/path/to/project$ which pip 
/path/to/project/venv/bin/pip
(venv) user@machine:/path/to/project$ pip -V
Traceback (most recent call last):
  File "/path/to/project/venv/bin/pip", line 7, in <module>
    from pip._internal.cli.main import main
  File "/path/to/project/venv/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

If I fix this specific syntax error, I get another error based on f-strings

How do a get a virtual environment for python3.5 with a working version of pip?

I know that python3.5 is reaching EoL, but it seems that python is just getting harder for me to use in general. Old projects are breaking because I can't use these old versions of python. So I'd like some insight on how to avoid errors like these in the future. Is the answer just to port these projects forward? Honestly, that's just a lot of work and it seems like old versions of python should just stay working. Maybe that's too much to ask and it's difficult to maintain these older versions of python?

Grifball
  • 756
  • 1
  • 5
  • 14
  • Python 3.5 is not *reaching* EoL, it is already EoL for over 5 years now (2015). And pip does not support Python 3.5 anymore. Time to upgrade. Inaction on tech debt has consequences ... :) – wim Feb 19 '21 at 19:41
  • downgrade pip to previous version that support 3.5 if you MUST keep working on 3.5 for reasons beyond your control. Otherwise upgrade to newer version of python – buran Feb 19 '21 at 19:43
  • @buran You can not downgrade pip with a broken pip installation.. – wim Feb 19 '21 at 19:46
  • @wim, my understanding from the error message is `pip` in the virtual environment is "broken". Recreating the virtual environment should be possible. system pip can/should be managed via system package manager (apt-get) - https://github.com/pypa/pip/issues/5599 Sorry if I misunderstand something and am wrong. – buran Feb 19 '21 at 19:56
  • @wim, also I think using `get-pip.py` it will be possible to downgrade even with broken `pip` – buran Feb 19 '21 at 20:06
  • @wim sorry, the requirement is actually Ubuntu 16.04, which doesn't seem to have Python3.6 installable by default. I got Ubuntu's 16's EoL confused with Python3.5. But Python3.5's EoL was only a couple months ago. I think I will try just using a ppa to get 3.6. Thanks to who ever linked to the duplicated, I couldn't find it. – Grifball Feb 19 '21 at 21:51
  • @HappyPandaFace Oops you're right, it was *released* 5 years ago and EoL 5 months ago. Anyway, you won't be able to downgrade with this pip, you'd have to create a venv anew and then install older version of pip directly. – wim Feb 19 '21 at 22:11
  • You can downgrade you pip to a compatible version using `curl https://bootstrap.pypa.io/2.7/get-pip.py --output get-pip.py` and then run `$(which python3.5) get-pip.py` . Please note that you'll need to perform this on the base pip(if it's broken) and also on the virtualenv. Please ensure that you do not have any scripts upgrading pip post that. could you also help with the virtualenv version ? – DhakkanCoder Feb 20 '21 at 08:41
  • @DhakkanCoder thanks, it seems that get-pip is critical to solve these issues. I've never used it though, and I'll have to look into it a bit more. I guess another solution would be to use an older version of pip, which was a problem I simply didn't suspect. Virtualenv version is ```15.0.1+ds-3ubuntu1``` – Grifball Feb 24 '21 at 20:22

0 Answers0