Process for migrating to Python3?

As of the latest version of Klipper Python3 is now supported but I can’t seem to get it migrated over.

After running the following the Klipper service fails to start.

sudo apt remove python2
sudo apt autoremove --purge

Also tried to install

sudo apt install python-is-python3

I am running FluidPi. Do I need to reinstall Klipper from scratch or something else? As soon as I sudo apt install python2 then Klipper starts without issue again.

Some parts may need python 2, and the code migration is not fully complete. Leaving python 2 installed should be fine.

Please be aware that you have absolutely no benefit / advantage in doing so.

Klipper use a virtual environment that is created with a defined Python version and needs to be recreated if changing the Python version.
You have two options:

sudo service klipper stop

# remove current klippy-env environment
cd ~
rm -rf klippy-env

# create new venv
virtualenv -p python3 klippy-env

#install new Klipper venv
cd ~/klippy-env
bin/pip install -r ../klipper/scripts/klippy-requirements.txt
4 Likes

The benefit is not using an end of life package that receives no security patches even for critical security vulnerabilities.

Oh, well. Of course a valid argument but whoever exposes his printer to the internet directly practically deserves to be the most-daft-bitcoin-mining-bot-net-member-of-the-month.

For all who rightfully refrain from doing it, the difference is basically zero even for the most critical vulnerabilities.


Edit, since I think it is really important:

  • Do NOT believe that upgrading to Python3 allows to expose your printer directly to the internet
  • Do NOT even remotely think about exposing your printer directly to the internet
  • Again, just do NOT do it
  • No, neither Klipper, nor Moonraker, nor fluidd / mainsail whatsoever

Exposing services to the internet is a very dangerous thing for the casual user that may endanger the integrity of your entire network, online-banking and every other ugly consequence you can think about.

It can be done but requires a lot of knowledge, solid planning and constant care / monitoring of the exposed systems.

If you absolutely think you need to do it:
In my opinion the only way for the average Joe (like myself) to do it halfway securely is using a VPN connection or VPN-like services, e.g NGROK or Cloudflare Zero Trust.
And again: You can even misconfigure these leaving you basically unprotected while thinking you are secure.

1 Like

I just saw that Debian pulled python 2.7 from unstable. Looks like it’s becoming time to make this happen. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1027108

Proper security practice is to set up security as if assuming someone has already infiltrated your network. Regardless of this I can not understand for the life of me why anyone would honestly recommend for any reason whatsoever to not move away from EOL software. I mean it is End Of life. The world has moved on from it and you should too. Not like we are a corporation where it would cost us licensing fees or man hours to switch.

You will also need to reinstall numpy for python 3 if you are using input shaper.

sudo apt update

sudo apt install python3-numpy python3-matplotlib libatlas-base-dev

~/klippy-env/bin/pip install -v numpy

sudo reboot
3 Likes