PIO upgrading actually downgraded

I was on the latest 5.1.1 and instead of upgrading, this command actually downgraded me:

:~/Code/platformio/test$ pio upgrade
Please wait while upgrading PlatformIO ...
PlatformIO has been successfully upgraded to 5.0.4
Release notes: https://docs.platformio.org/en/latest/history.html

This was revealed by the next command:

:~/Code/platformio/test$ pio update
*******************************************************************************************************************************************************************************
Obsolete PIO Core v5.0.4 is used (previous was 5.1.1)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/page/faq.html#multiple-platformio-cores-in-a-system
*******************************************************************************************************************************************************************************

Python 2 and Python 3.5 are not compatible with PlatformIO Core 5.0.
Please check the migration guide on how to fix this warning message:

https://docs.platformio.org/en/latest/core/migration.html#drop-support-for-python-2-and-3-5

Any further pio upgrade command results in the exact same response as the first one above.
Why does this even happen, and how can I now make a true upgrade to the latest version?

I’m running pio on vscode on Ubuntu 16.04 in a venv with Python 3.9.4.

That’s… weird. Does pio upgrade --dev get you to 5.2.0b1?

This outcome:

:~/Code/platformio/test$ pio upgrade --dev
Please wait while upgrading PlatformIO ...
Error: ['/usr/bin/python3', '-m', 'pip', '--no-cache-dir', 'install', '--upgrade', '/home/ullix/.platformio/.cache/piocoredevelop.zip']
Defaulting to user installation because normal site-packages is not writeable
Processing /home/ullix/.platformio/.cache/piocoredevelop.zip
Requirement already satisfied: bottle==0.12.* in /usr/lib/python3/dist-packages (from platformio==5.2.0b1) (0.12.7)
Requirement already satisfied: click<9,>=5 in /usr/local/lib/python3.5/dist-packages (from platformio==5.2.0b1) (7.0)
Requirement already satisfied: colorama in /usr/local/lib/python3.5/dist-packages (from platformio==5.2.0b1) (0.4.1)
Requirement already satisfied: marshmallow<4,>=2 in /home/ullix/.local/lib/python3.5/site-packages (from platformio==5.2.0b1) (3.12.2)
Requirement already satisfied: pyelftools<1,>=0.27 in /home/ullix/.local/lib/python3.5/site-packages (from platformio==5.2.0b1) (0.27)
Requirement already satisfied: pyserial==3.* in /home/ullix/.local/lib/python3.5/site-packages (from platformio==5.2.0b1) (3.5)
Requirement already satisfied: requests==2.* in /usr/lib/python3/dist-packages (from platformio==5.2.0b1) (2.9.1)
Requirement already satisfied: semantic_version==2.8.* in /usr/local/lib/python3.5/dist-packages (from platformio==5.2.0b1) (2.8.2)
Requirement already satisfied: tabulate==0.8.* in /usr/local/lib/python3.5/dist-packages (from platformio==5.2.0b1) (0.8.5)
Collecting zeroconf==0.33.*
  Downloading zeroconf-0.33.4-py3-none-any.whl (89 kB)

DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
ERROR: Could not find a version that satisfies the requirement aiofiles==0.7.* (from platformio)
ERROR: No matching distribution found for aiofiles==0.7.*


* Upgrade using `pip install -U platformio`
* Try different installation/upgrading steps:
  https://docs.platformio.org/page/installation.html

I have a hunch, this has to do with venv. Ubuntu 16.04 still has Python3.5. In order to use vscode and pio, I have to activate a venv. Here output from a gnome-terminal on the OS:

(vgl39) ullix@crucialmx200:~$ python --version
Python 3.9.4

However, I get the very same response when I do this in a terminal within pio:

ullix@crucialmx200:~/Code/platformio/test$ python --version
Python 3.9.4

Looks like the pio commands ignore the venv?

Doesn’t help to do it from a venv in an OS terminal which definitively has Py3.9:

(vgl39) ullix@crucialmx200:~$ pio upgrade 
Please wait while upgrading PlatformIO ...
PlatformIO has been successfully upgraded to 5.0.4
Release notes: https://docs.platformio.org/en/latest/history.html

Same with pio update:

(vgl39) ullix@crucialmx200:~$ pio update
*******************************************************************************
Obsolete PIO Core v5.0.4 is used (previous was 5.1.1)
Please remove multiple PIO Cores from a system:
https://docs.platformio.org/page/faq.html#multiple-platformio-cores-in-a-system
*********************************************************************************
Python 2 and Python 3.5 are not compatible with PlatformIO Core 5.0.
Please check the migration guide on how to fix this warning message:

https://docs.platformio.org/en/latest/core/migration.html#drop-support-for-python-2-and-3-5

I don’t think I have multiple pio cores, at least never installed them knowingly. How can I check for my number of cores?

Try to uninstall PlatformIO completely, pip uninstall platformio in the system python and and python envs you have. Remove the master-folder /home/<user>/.platformio/ too to uninstall it completely.

Then try a clean install again through the recommended method: Redirecting.... This will basically install a Pyenv in <user home>/.platformio/penv/. Follow the instructions to add that to a path then.

Back in business.

I found 2 pio installations on my system:

  • platformio 5.0.4 on /home/ullix/.local/bin/*
  • platformio 4.0.3 on /usr/local/bin/*

This magic line:

python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"

smoothly did the installation.

However, I had to run it from a venv - Py3.9 in this case - it would not run from Py3.5.

I am wondering is that really necessary that I need a venv in order to create yet another venv, when even with that new venv, pio wants to be started from a venv with Py>=3.6 ?

But according to the output I am now also the proud owner of an exe file!

The full path to `platformio.exe` is `/home/ullix/.platformio/penv/bin/platformio`

The Python installer script itself seems to have some dependencies to Python 3.6+ per this. Would of couse be nicer if didn’t need that high of a Python version to run.

So pio upgrade gets you to the latest stable version now right?

$ pio upgrade
You're up-to-date!
PlatformIO 5.1.1 is currently the newest version available.

But, of course, now only inside pio. On an OS terminal in a Py3.9 venv I get:

$ pio upgrade
bash: /usr/local/bin/pio: Datei oder Verzeichnis nicht gefunden

Please remove all global PlatformIO installations and use an official installer script.

If you need pio command in your terminal, see https://docs.platformio.org/en/latest/core/installation.html#install-shell-commands.

???

Isn’t that exactly what I did thanks to the guidance of @maxgerhardt as given here:

If it is different, what problems can I expect? So far running as it should.