Python update

Hi. I try to update python with different command but still I have in the nofification area, when I update home assistant, the message:
python 3.5 support is deprecated and will be removed in the firs relase after August 1. Please upgrade Python.

Have anyone a solution?
This is the command that I use to usually upgrade Home assistant:

sudo apt-get update
sudo apt-get -y upgrade
sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip3 install --upgrade homeassistant
$ exit

and I tried this to upgrade python:

sudo apt-get update
sudo apt-get install python 3.6
sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev -y
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
tar xzvf Python-3.6.4.tgz
cd Python-3.6.4/
./configure
make
sudo make install

Thank you and regards

Are you using hassbian? If so https://github.com/home-assistant/hassbian-scripts/blob/dev/docs/suites/python.md

You may as well go directly to Python 3.7.x, which is what you’ll get if you use Hassbian and upgrade through the Hassbian scripts (you may need to upgrade the Hassbian scripts first).

I’d also highly recommend make altinstall to avoid over-writing the existing version of Python.

Now…

If you can do that, you don’t need to compile Python.

Looks like you may be missing some key things, like libuuid. Here’s what I use:

$ sudo aptitude install build-essential tk-dev libncurses5-dev libncursesw5-dev \
  libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev \
  libexpat1-dev liblzma-dev zlib1g-dev libudev-dev

(package versions may be slightly outdated, I need to check that)

When I upgraded with an altinstall I used the Hassbian script as a guide. Its dependencies seem to work well.

Hi,
I don’t know. In wich way I can understand if I have hassbian?
If I try:
sudo hassbian-config upgrade python
the result is:

pi@raspberrypi:~ $ sudo hassbian-config upgrade python
sudo: hassbian-config: comando non trovato

Did you flash your SD card with Hassbian initially?

I think I manually install home assistant.
I use this command to update home assistant:

sudo apt-get update
sudo apt-get -y upgrade
sudo -u homeassistant -H -s
$ source /srv/homeassistant/bin/activate
$ pip3 install --upgrade homeassistant
$ exit

I hope there is a simple solution to update python? Thank you

If they had used Hassbian and read the Release Notes, they would have used the Hassbian script to upgrade python. :wink:

My initial guide took 20 steps but it looks like you may have already updated Python in the OS. In just the OS what is the output of python3 --version and python36 --version ?
That would help me determine the next steps.
It appears you are part way there. We just need to verify that.

This is the output:

pi@raspberrypi:~ $ python3 --version
Python 3.6.4
pi@raspberrypi:~ $ python36 --version
-bash: python36: comando non trovato

is correct? This is the output in the main system, I don’t know how check the python in the virtual enviroment.

That tells me what I need to see. The following should work when logged in as the homeassistant user.

  1. sudo systemctl stop [email protected]
  2. sudo mv /srv/homeassistant /srv/homeassistant_old
  3. sudo mkdir /srv/homeassistant
  4. sudo chown homeassistant:homeassistant -R /srv/homeassistant
  5. cd /srv/homeassistant
  6. python3 -m venv .
  7. source bin/activate
  8. pip install wheel homeassistant
    9a. ** Note I chose to run hass first time to see all the installation messages.**
    9b. sudo systemctl start [email protected]

Sorry but if I try the first command I retreive this:

Failed to stop [email protected]: Unit [email protected] not loaded.
(homeassistant) homeassistant@raspberrypi:/home/pi $

and looks like the verion of python is 3.5:
(homeassistant) homeassistant@raspberrypi:/home/pi $ python3 --version
Python 3.5.3

type these two commands to maybe figure out better what you’re running:

lsb_release -a
cat /etc/issue

But earlier you said

Which is it? To be sure we can do the full altinstall. I will post it next.

1, sudo apt-get install build-essential tk-dev libncurses5-dev libncursesw5-dev libreadline6-dev libdb5.3-dev libgdbm-dev libsqlite3-dev libssl-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev
2. wget -O /tmp/Python-3.7.3.tar.xz https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz
3. cd /tmp
4. tar xf Python-3.7.3.tar.xz
5. cd Python-3.7.3
6. ./configure
7. sudo make altinstall
8. sudo apt -y autoremove
9. cd
10. sudo rm -r /tmp/Python-3.7.3
11. sudo rm /tmp/Python-3.7.3.tar.xz
12. sudo systemctl stop [email protected]
13. sudo mv /srv/homeassistant /srv/homeassistant_old
14. sudo mkdir /srv/homeassistant
15. sudo chown homeassistant:homeassistant -R /srv/homeassistant
16. cd /srv/homeassistant
17. /usr/local/bin/python3.7 -m venv .
18. source bin/activate
19. pip install wheel homeassistant
20a. ** Note I chose to run hass first time to see all the installation messages.**
20b. sudo systemctl start [email protected]

1 Like

Why not just upgrade to buster and be done with it? Why install another version of python?

Perhaps we do not want to run an unstable system on an unstable, unreleased OS. There are stability reasons Buster is not yet released.

If you have HA on an unstable OS, how do you know which is causing breakage? Some people actually try to use HA for home automation rather than just a hobby.

1 Like

I think you mis-understand the debian naming system and what their definition of unstable means. Each to their own.

It Debian Next which is not YET released as stable so, by definition, it is unstable but not as unstable as sid.

Sorry but happens a disaster. I tried your step but:

POINT 12
pi@raspberrypi:~ $ sudo systemctl stop [email protected]
Failed to stop [email protected]: Unit [email protected] not loaded.

POINT 17
pi@raspberrypi:/srv/homeassistant $ . /usr/local/bin/python3.7 -m venv .
-bash: .: /usr/local/bin/python3.7: impossibile eseguire il file binario

then I try:

pi@raspberrypi:/srv/homeassistant $ /usr/local/bin/python3.7 -m venv .
Error: [Errno 13] Permission denied: ‘/srv/homeassistant/include’

then I try:

pi@raspberrypi:/srv/homeassistant $ sudo /usr/local/bin/python3.7 -m venv .
pi@raspberrypi:/srv/homeassistant $

POINT 19
at the end I received this message:

Could not install packages due to an EnvironmentError: [Errno 13] Permesso negato: ‘/srv/homeassistant/lib/python3.7/site-packages/wheel-0.33.4.dist-info’
Consider using the --user option or check the permissions.

then I try:

sudo pip install wheel homeassistant

Now Home assistant is not working! I’m not able to access via ipaddress:8123.

Could you help me please?