Update Python in Virtual Environment

Hi,

Home Assistant is asking me to upgrade from Python to 3.7.3 to 3.8.0 before December. Is this possible in an existing virtual environment? What do I need to do to keep my HASS installation?

Thanks & Regards

You’ll need to install the new version of Python (preferably using altinstall) and create a new venv

…or switch to Docker and then you won’t need to worry about Python versions.

I did this a couple of weeks ago on my setup.

You’re going to want to make a backup copy of your current /config and virtualenv, just in case you need to revert.

Download and compile new python using the altinstall target. Compiling is a pretty straight forward process, plenty of documentation available online, so should be smooth sailing.

I installed mine to a location in my $PATH rather than a system-wide install.

After that’s done, you’ll need to create a new virtualenv using the newly installed Python binary to use with Home Assistant.

You will probably get some sort of error complaining about the database being corrupt, so it’s probably best practice to delete config/home-assistant_v2.db or rename it to a different file name.

If by chance you are using Ubuntu bionic 18.04.x, you may be able to update Python to 3.8.0 from the Ubuntu distribution (at least for amd64).

$ sudo apt install python3.8
$ sudo apt install python3.8-venv 
$ sudo apt install python3.8-dev

I’m using Raspbian and followed these steps. Worked without any issues.