Python 2 to python3

Not used my printer in quite a while as the wife has been seriously ill ive just had a message pop about ime using python 2 version 17 so my question is can i update to python 3 through octoprint or do i have to reflash a image of octoprint python 3 to the sd card Any help gratefully reseved

Hello,
you didn't mention which version of octopi you're running, if any. With 0.17 python is installed there already, just not used and there is a script to easily change that. With older versions the recommended way is to make a backup first and store it at a safe place. Then reflash with a current octopi 0.18 or, even better, get a new sd card and flash it. Those cards don't get better over time and you'll have a fallback.
Search the forum for details, the question has come up repeatedly the last few days.

Manythanks for the reply i havent got many plugins so will do a complete new fresh install of the latest 0.18 on a seperate card

The notification gives you a link to the post below, that explains what needs to be done to upgrade:

My question? I am running Octoprint v1.6.1 I have no issues with it at all. I do not need any plugins above the very few I already have. So, why do i need to upgrade python anyway? If it ain't broke don't fix it.
Is there some easy way to make an exact copy for backup, in case the SD card fails? That might be a good idea...

  • In future, OctoPrint will drop support for Python 2 because it is too old.
  • ~40 plugins (iirc) only support Python 3 now, because developers don't work with old systems anymore
  • Every update we try and push out requires patches and workarounds because 3rd party dependencies are dropping Python 2, like OctoPrint will. This takes up development time, and leaves it vulnerable to security issues as the dependencies are updated to patch bugs.

~60% of all users have migrated to Python 3 already, and so this means you will get left behind, as it is viable for us to move on - new plugins, plugin updates, OctoPrint updates, etc.

In terms of the backup question, you can create a backup using the built-in backup & restore functionality which will work for all of the OctoPrint stuff (config, plugins, files), which is all most need. Otherwise you are taking an image of the entire SD card, which is possible but can be quite a lot of work, and takes up a lot of storage if you have a lot of stuff installed.

2 Likes
  • shutdown the pi (from the OctoPrint system menu or from a shell with sudo halt
  • take the sd card out and move over to a computer with a bash shell and a real hard drive in terms of free space
    • a linux box
    • an OSX box
    • a virtual machine on anything
    • even windows comes with a linux subsystem (but I never tried it),
    • if you're on something win*ancient, there always is cygwin
  • on the shell type lsblk (and enter)
  • now insert the sd card to a card reader attached to that box ...
  • input lsblk again and look what has changed. You are looking for a new device with 2 partitions
    • the smaller one listed with the mount point /boot and
    • the larger on as /
  • you need the device name of that new item, sdX. Do not confuse it with the partition names, sdX1, sdX2
  • where do you plan to store the image? go there.
    cd ~/storeage/images
  • all of the above was just setting the context for the one-liner:
    sudo dd if=/dev/sdX of=sd-card-copy.img bs=1M status=progress
  • now here comes the hard part: you need to be patient. Check twitter or something.
1 Like

my question is can i just flash the image using the raspberry image tool so that ime running on python 3 and were it says set host name" raspberrypi .local can i replace it with my "__________.local name i created all ready and just do the restore option as ive made a back up MANY THANKS for tacking your time helping us out

You can give a different hostname for your raspi but I can't tell you anything about the tool you mentioned as I usually flash sd cards with dd and do the config with ssh and a text editor.
Valid characters for hostnames are ASCII(7) letters from a to z, the digits from 0 to 9, and the hyphen (-). A hostname may not start with a hyphen

Yes, setting your hostname in Raspberry Pi Imager works

Brilliant many thanks as ime not very techy so need the simple way had a nightmare last time using the commandss . so that ive got it strait using my existing host name will take me straight back in without having to restore as ive got no plugins many thanks for taking your time to help