Python upgrade

Oh sorry - I confused you with the OP

No problem. I was going to make a separate post but this is something that will run as soon as venv users start upgrading to 0.94.

I would strongly recommend leaving the distributionā€™s Python alone and installing 3.7.3 with pyenv (pyenv-install). That way you donā€™t mess up anything that depends on the system Python.

https://github.com/pyenv/pyenv-installer

You probably need some prerequisites to build Python:

sudo apt libbz2-dev install libbz2-dev libncursesw5-dev libsqlite3-dev uuid-dev libreadline-dev libssl-dev

Follow the instructions on the pyenv installer page to configure your shell, then build 3.7.3:

pyenv install 3.7.3
pyenv shell 3.7.3
python -m venv [name of venv (such as homeassistant)]
[name of venv]/bin/activate
pip install homeasssitant, etc (follow HA instructions)

5 Likes

I compiled and installed python 3.7.3 on my raspberry.

I also run home assistant in a venv like you. What you can do is[1]:
python3 -m venv --upgrade /srv/homeassistant/(or whereever your homeassistant directory is).

A short ls will show:

$ ls /srv/homeassistant/lib/
python3.5  python3.7

I still donā€™t know how to go from here because home assistant still launches from 3.5. But we will figure it out :wink:

[1] https://docs.python.org/3/library/venv.html

I have 2.7 running along side 3.5 and 3.7, as long as you donā€™t adjust the symlink to /usr/bin/python3 you donā€™t cause problems.

Or as froz suggested give pyenv a shot.

Thanks for that.

As Python 3.6 or greater is not currently in the Raspbian Stretch repos and we donā€™t have a version of Raspbian Buster it means that Python needs to manually downloaded and built.

What Iā€™m trying to put together here is a procedure to manually download and build a version of Python outside of the current repo and then replace my current Python Hass venv with this newly built version.

Why do you say that? I update python, and then replace the link so that it does use the newly installed version. This then means no upgrade of venv is required, it just uses it from there out. No issues through the last 12 months that I know of.

When I symlinked python3 to 3.7 i was getting some errors, could have just been a missing dep, but I reverted the link anyways.

I have a venv setup with HASS in it and itā€™s working fine, also wanted a new venv as the old one had some very very old pyozw hacks still lurking about in it that I didnā€™t want/need anymore :wink:

Great!
For increased instability we now use a problem-prone application on a buggy OS and need to determine which part is causing a particular issue.

People use Hassbian because, like Hassio HassOS, it is a complete image for those who have advanced a little beyond the beginner stage & want more flexibility/customization. Yes, the real techies can ā€œroll their ownā€ but many of us do too much of that for our job and want things that work fairly reliably.

For now I am stepping back & considering my options.

1 Like

+1 here too.

The last couple of updates have been so time consuming my HA server has had more downtime than uptime trying to resolve the issues.

My current install 0.93.2 appears to be quite stable at the moment so until I can work out a definitive way of progressing beyond it and the Python issue Iā€™m afraid Iā€™ll be like Moses as far as the the great Home Assistant v 1.0 project is concerned. I made the journey but I wonā€™t get to see it :sob:

1 Like

We need to find Joshua :smiley:

Or even The Holy Grail that is HA v1.0. Now that will be interesting to witness :laughing:

1 Like

I feel like Caleb, the old man along for the ride :wink:

1 Like

I am running Raspbian Stretch Lite with Python 3.5.3, with HA in a venv. As you I am searching a reliable way to update to Python 3.7.3. It seems that it can be done with code from this link. I still havenā€™t done, maybe this weekend. I want to do a SD backup first, in case something go wrong.

I guess I need a bit more help. I am still running on my original All In One Installer. When I upgrade HA I use the commands
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/homeassistant_venv/bin/activate
pip3 install --upgrade homeassistant
I followed the procedure at my normal login but my HA is still showing python version 3.5.3. I tried to do the procedure within
sudo su -s /bin/bash homeassistant
source /srv/homeassistant/homeassistant_venv/bin/activate
but when I get to sudo make install I get a prompt asking for homeassistant password. I have tried every password I have ever used on the pi and HA and nothing works. Any help would be appreciated. Thanks

Of course it will. All youā€™re doing is updating Hass and not the Python end it is installed in.

As I mentioned so many looking for guidance on this subject.

I will attempt to pull all the suggestions that were made together and see if I can come up with a simple copy/paste set of instructions to achieve this.

Any Hass venv users please feel free to pitch in on this. This is something all venv users can use going forward.

I can throw out some untested ideas.

  1. Upgrade python on your OS.
  2. In your venv run pip freeze > requirements.txt This creates a file with the installed python modules.
  3. Stop Home Assistant
  4. Delete the old venv (need to verify how)
  5. Create a new venv In /srv/homeassistant, run
$ sudo -u homeassistant -H -s
$ cd /srv/homeassistant
$ python3 -m venv .
$ source bin/activate
  1. Install the modules pip install -r requirements.txt
  2. Start Home Assistant
  3. ?? Profit ??

Thatā€™s definitely taking shape along the lines I was thinking.

From what I was reading you can have as many different versions of Python on your system as long as they are isolated in separate folders from each other.

So as Iā€™m reading it you need to do the following

  1. Download the Python source of your choice into your chosen folder

  2. Build the binaries

  3. Install those binaries

  4. Create the venv

  5. Restore your HA config to the new venv

Have I missed anything here.

Well technically your HA config lives outside of the venv in /home/homeassistant/.homeassistant/, your venv of python lives in another directory ie: /srv/homeassistant/

No need to restore anything as the config doesnā€™t go anywhere.

1 Like