Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Instruction Guide Python update
#1
Hi Tim,
Is it safe to update Python from 2.7.16 to version 3.8?
Reply
#2
afaik the python 3 packages aren't an update of python 2 they're separate packages, thus you can have python 2 and python 3 installed simultaneously.
Then I think the default python instance is configured with the update-alternatives command.
Not near a Debian or RaspiOS machine at the moment so can't be sure.
Reply
#3
Python 3 is already on the moOde image. like @vinnn  mentioned there is prolly some config that has to be run to make Python 3 the default.

Code:
pi@moode:~ $ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#4
So let's take a look at the /usr/bin/ directory

Code:
pi@rpi4b2:~ $ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       7 Mar  4  2019 /usr/bin/python -> python2
lrwxrwxrwx 1 root root       9 Mar  4  2019 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 2984816 Oct 10  2019 /usr/bin/python2.7
lrwxrwxrwx 1 root root      36 Oct 10  2019 /usr/bin/python2.7-config -> arm-linux-gnueabihf-python2.7-config
lrwxrwxrwx 1 root root      16 Mar  4  2019 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 Mar 26  2019 /usr/bin/python3 -> python3.7
-rwxr-xr-x 2 root root 4275580 Jul 25  2020 /usr/bin/python3.7
lrwxrwxrwx 1 root root      36 Jul 25  2020 /usr/bin/python3.7-config -> arm-linux-gnueabihf-python3.7-config
-rwxr-xr-x 2 root root 4275580 Jul 25  2020 /usr/bin/python3.7m
lrwxrwxrwx 1 root root      37 Jul 25  2020 /usr/bin/python3.7m-config -> arm-linux-gnueabihf-python3.7m-config
lrwxrwxrwx 1 root root      16 Mar 26  2019 /usr/bin/python3-config -> python3.7-config
lrwxrwxrwx 1 root root      10 Mar 26  2019 /usr/bin/python3m -> python3.7m
lrwxrwxrwx 1 root root      17 Mar 26  2019 /usr/bin/python3m-config -> python3.7m-config
lrwxrwxrwx 1 root root      14 Mar  4  2019 /usr/bin/python-config -> python2-config

  • note that python3.8 isn't installed in RaspiOS 10.6; it would have to be 
  • pythonic programmers will usually invoke the specific python version they want 
  • the symlink /usr/bin/python can be changed to point to the version of choice
However, directly changing that symlink is old-style Linux administration. The new style (at least in Linux'es derived from Debian) is to use the alternatives system.

Here's the start of the man page for update-alternatives

Quote:update-alternatives(1)                                       dpkg suite                                       update-alternatives(1)

NAME
       update-alternatives - maintain symbolic links determining default commands

SYNOPSIS
       update-alternatives [option...] command

DESCRIPTION
       update-alternatives  creates,  removes,  maintains  and  displays  information about the symbolic links comprising the Debian
       alternatives system.

       It is possible for several programs fulfilling the same or similar functions to be installed on a single system at  the  same
       time.   For  example,  many systems have several text editors installed at once.  This gives choice to the users of a system,
       allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice for an editor
       to invoke if the user has not specified a particular preference.

       Debian's  alternatives  system aims to solve this problem. ...

I'm a dinosaur stuck in old style LInux. Rather than try to explain the alternatives system I'll leave it at "use your favorite search engine."

Regards,
Kent
Reply
#5
(10-11-2021, 03:33 PM)vinnn Wrote: afaik the python 3 packages aren't an update of python 2 they're separate packages, thus you can have python 2 and python 3 installed simultaneously.
Then I think the default python instance is configured with the update-alternatives command.
Not near a Debian or RaspiOS machine at the moment so can't be sure.
gotcha
Reply
#6
(10-11-2021, 03:51 PM)Tim Curtis Wrote: Python 3 is already on the moOde image. like @vinnn  mentioned there is prolly some config that has to be run to make Python 3 the default.

Code:
pi@moode:~ $ python3
Python 3.7.3 (default, Jul 25 2020, 13:03:44)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Yes, I see
Reply
#7
(10-11-2021, 04:45 PM)TheOldPresbyope Wrote: So let's take a look at the /usr/bin/ directory

Code:
pi@rpi4b2:~ $ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       7 Mar  4  2019 /usr/bin/python -> python2
lrwxrwxrwx 1 root root       9 Mar  4  2019 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 2984816 Oct 10  2019 /usr/bin/python2.7
lrwxrwxrwx 1 root root      36 Oct 10  2019 /usr/bin/python2.7-config -> arm-linux-gnueabihf-python2.7-config
lrwxrwxrwx 1 root root      16 Mar  4  2019 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 Mar 26  2019 /usr/bin/python3 -> python3.7
-rwxr-xr-x 2 root root 4275580 Jul 25  2020 /usr/bin/python3.7
lrwxrwxrwx 1 root root      36 Jul 25  2020 /usr/bin/python3.7-config -> arm-linux-gnueabihf-python3.7-config
-rwxr-xr-x 2 root root 4275580 Jul 25  2020 /usr/bin/python3.7m
lrwxrwxrwx 1 root root      37 Jul 25  2020 /usr/bin/python3.7m-config -> arm-linux-gnueabihf-python3.7m-config
lrwxrwxrwx 1 root root      16 Mar 26  2019 /usr/bin/python3-config -> python3.7-config
lrwxrwxrwx 1 root root      10 Mar 26  2019 /usr/bin/python3m -> python3.7m
lrwxrwxrwx 1 root root      17 Mar 26  2019 /usr/bin/python3m-config -> python3.7m-config
lrwxrwxrwx 1 root root      14 Mar  4  2019 /usr/bin/python-config -> python2-config

  • note that python3.8 isn't installed in RaspiOS 10.6; it would have to be 
  • pythonic programmers will usually invoke the specific python version they want 
  • the symlink /usr/bin/python can be changed to point to the version of choice
However, directly changing that symlink is old-style Linux administration. The new style (at least in Linux'es derived from Debian) is to use the alternatives system.

Here's the start of the man page for update-alternatives

Quote:update-alternatives(1)                                       dpkg suite                                       update-alternatives(1)

NAME
       update-alternatives - maintain symbolic links determining default commands

SYNOPSIS
       update-alternatives [option...] command

DESCRIPTION
       update-alternatives  creates,  removes,  maintains  and  displays  information about the symbolic links comprising the Debian
       alternatives system.

       It is possible for several programs fulfilling the same or similar functions to be installed on a single system at  the  same
       time.   For  example,  many systems have several text editors installed at once.  This gives choice to the users of a system,
       allowing each to use a different editor, if desired, but makes it difficult for a program to make a good choice for an editor
       to invoke if the user has not specified a particular preference.

       Debian's  alternatives  system aims to solve this problem. ...

I'm a dinosaur stuck in old style LInux. Rather than try to explain the alternatives system I'll leave it at "use your favorite search engine."

Regards,
Kent

Thank you! So I was able to change the default python to 3.x from 2.x, however, the shutdownchecksetup.sh for my ATXRaspi does not seem to work even though I reinstalled and rebooted. Changed the default back to Python 2.x, reinstalled the shutdownchecksetup.sh and rebooted. Got the ATXRaspi working as before. I guess there is a way to choose which version of Python to run on the fly? Will need to investigate further.

Basiclly, I found this: https://sxm-player.readthedocs.io/en/latest/readme.html and trying to get it to work within Moode.
Reply


Forum Jump: