OctoPrint tells me my Python environment is outdated and will soon no longer be supported, how do I upgrade?

Thanks for this correction. :smiley:
This update is driving me crazy. :exploding_head:

Sudo or no sudo - I've tried both because nothing works. It happens often enough that sudo is omitted in descriptions even though it is required.
Python 3.13 is installed, but /usr/bin/python3.13 does not exist.
This means that the command does not work as specified:
./octoprint-venv-tool recreate-venv /home/pi/oprint --python /usr/bin/python3.13
--->Error running recreate-venv: [Errno 2] No such file or directory: '/usr/bin/python3.13'
2025-06-06 migration errors2

if you type python --version and python3 --version what is listed? if either of those return 3.13, then you can type which python or which python3 to get the path to that specific binary.

I was about to say: You made my day (and many others).

The binary for python 3.13 is /usr/local/bin/python3.13- for whatever reason.

Now I could start the migration - but unfortunately it cancelled again with an error:

> Error running recreate-venv: Command '('/home/pi/oprint/bin/python', '-m', 'pip', 'install', 'https://github.com/cmuche/octoprint-timelapseplus/archive/master.zip')' returned non-zero exit status 1.

Looks like it hung up on timelapse plus plugin, but OctoPrint was installed.

After what felt like 100 attempts, I managed to perform the migration twice in total.

Previously I had to remove almost all 3rd party plugins.

Octoprint is running - but: I can no longer log in to Octoprint with the Octoprint user/password, the password is now invalid!

What now?
20250610 WrongUsernameOrPasswordAfterMigration

Whew! With the help of ChatGpt, I was able to create a new user and log in again.

jneilliii and ChatGpt, you saved me, thanks for your patience!

Simple search here would have helped too.

Ok, but I haven't forgotten it, it was just no longer valid - for whatever reason.
Anyway, the problem is solved

If you're running the OctoPi image and need a newer Python version, here’s how I upgraded OctoPrint to Python 3.11 without reflashing.


  1. Build and install Python 3.11 (takes a while)
cd /usr/src
sudo wget https://www.python.org/ftp/python/3.11.9/Python-3.11.9.tgz
sudo tar xzf Python-3.11.9.tgz
cd Python-3.11.9
sudo apt install -y build-essential libssl-dev zlib1g-dev libncurses5-dev \
    libffi-dev libsqlite3-dev libreadline-dev libbz2-dev
sudo ./configure --enable-optimizations
sudo make -j$(nproc)
sudo make altinstall

(it might complain about sudo and pip but just ignore it)


  1. Stop OctoPrint

sudo systemctl stop octoprint


  1. Download the OctoPrint venv tool
curl -LO https://get.octoprint.org/octoprint-venv-tool
chmod +x octoprint-venv-tool

Edit the first line of the script so it reads:

#!/usr/bin/env python3 ( i had to do this because /bin/env didn't exist on my pi )


  1. Run the venv tool.

./octoprint-venv-tool recreate-venv /home/pi/oprint --python /usr/local/bin/python3.11

(If you don’t know your venv path, run find /home/pi -name activate and look for the parent directory just before /bin.)


  1. Restart OctoPrint

sudo systemctl start octoprint


:white_check_mark: Done! OctoPrint should now be running under Python 3.11.

5 Likes

I just rebuilt my OctoPi system in the past six months, and now I have to do it again. How often is this going to be happening? How often am I going to have to backup my settings, do a completely new installation and restore my settings? I've also got OctoDash running, so I have to account for that as well.

See Python | endoflife.date

I try my best to support Python versions for at least a year longer than their official EOL, or even more if the latest OctoPi requires that, but longer than that it's really not going to work anymore as the dependencies these days also stop supporting EOL versions faster than they used to, and that means that keeping things supported on a Python version that doesn't even get security fixes anymore means a TON of support overhead that simply doesn't work anymore if y'all also want bug fixes, features, improvements. Remember that I'm maintaining OctoPrint mostly on my own, and I'm also the only full time developer. I can't keep supporting Python versions that don't have any support from their own upstream anymore, that simply doesn't work anymore.

You can of course continue to use OctoPrint with Python versions that have been declared EOL, however new updates at some point will no longer support these and you won't be able to update to them anymore until you update your underlying Python version.

In general, when updating/migrating to a new Python version I can only recommend to go to the newest supported by OctoPrint rather than the oldest. Currently that would be 3.13 which will be officially supported until October of 2029.

Please also note that the recent ping about that from the healthcheck plugin regarding Python 3.9 also tells you that OctoPrint 1.12.0 that's currently in development will still support 3.9: that version is planned to get released some time early 2026. OctoPrint 1.13.0 most likely won't launch until late 2026 or even early 2027. Consider it an early heads-up.

Finally, there's a migration tool in the shape of the venv-tool mentioned above too, that should make this easier even in case of manual installs.

2 Likes

Hi
i just installed a new Octopi with Raspberry Imager, like suggested, but after Restart the same Error Message regarding Phyton 3.9 spawned!

Did i do something wrong?

i used the new camera stack version, that should be 30.September 25 ?!?

TIA

I downloaded the image manually, flashed it to a USB stick, and installed it on my RPi 4B. It shows:

OctoPrint 1.11.3 Python 3.11.2 OctoPi* 1.1.0cam (build 2025.09.30.141704)

If the image you flashed through the RPi Imager shows Python 3.9, then I don't think it downloaded the right image. @foosel might want to know this.

You can download the image manually and in the RPi Imager Use custom. See https://community.octoprint.org/t/new-new-camera-stack-rpi-images/64924/4

I just flashed the OctoPi (new camera stack) image from the RPi Imager (1.9.6) and it comes up as 1.1.0cam, Python 3.11.2

I also flashed the custom image via Raspberry Pi Imager, and I have python 3.11:

$ python --version
Python 3.11.2

image

Perhaps some caching issue?
jan

i will start from scratch and deinstall imager and so and then try again. as shown, it should be the right image! wish me luck :slight_smile:

Update: Now seem´s the new Image Version is Installed and all is OK.
I Hope the Restore of the Backup will not mess something :wink:

This doesn't look promising and when I reloaded octoprint, it still says I need to upgrade. So it failed.

stderr:
ERROR: Exception:
Traceback (most recent call last):
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 107, in _run_wrapper
    status = _inner_run()
             ^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 98, in _inner_run
    return self.run(options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 71, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 393, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 79, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 538, in collect_root_requirements
    reqs = list(
           ^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 494, in _make_requirements_from_install_req
    cand = self._make_base_candidate_from_link(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 226, in _make_base_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
                                       ^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 309, in __init__
    super().__init__(
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 162, in __init__
    self.dist = self._prepare()
                ^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 239, in _prepare
    dist = self._prepare_distribution()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 320, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 537, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 652, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/operations/prepare.py", line 77, in _get_prepared_distribution
    abstract_dist.prepare_distribution_metadata(
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/distributions/sdist.py", line 72, in prepare_distribution_metadata
    self.req.prepare_metadata()
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/req/req_install.py", line 594, in prepare_metadata
    self._set_requirement()
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_internal/req/req_install.py", line 397, in _set_requirement
    if isinstance(parse_version(self.metadata["Version"]), Version):
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_vendor/packaging/version.py", line 56, in parse
    return Version(version)
           ^^^^^^^^^^^^^^^^
  File "/home/paul/oprint/lib/python3.11/site-packages/pip/_vendor/packaging/version.py", line 202, in __init__
    raise InvalidVersion(f"Invalid version: {version!r}")
pip._vendor.packaging.version.InvalidVersion: Invalid version: 'refs-pull-718-head'

Installing plugin octolapse from https://github.com/FormerLurker/Octolapse/archive/master.zip failed: Command '('./oprint/bin/python', '-m', 'pip', 'install', 'https://github.com/FormerLurker/Octolapse/archive/master.zip')' returned non-zero exit status 2.
Recreation of ./oprint failed, restoring previously created backup...
... done!
Error running recreate-venv: Command '('./oprint/bin/python', '-m', 'pip', 'install', 'https://github.com/FormerLurker/Octolapse/archive/master.zip')' returned non-zero exit status 2.

That's an issue with one of your installed third party plugins over which I have no control.

I actually added --ignore-plugin-errors to venv-tool for this very reason, see the note on GitHub - OctoPrint/venv-tool: Command line tool for various tasks for OctoPrint venvs

I see. I think I managed to invoke it properly but the detailed instructions above might want to include it. Does deactivating 3rd party plugins help clear this hurdle or do they have to be uninstalled? I only have two so I am not dependent on them.

You can keep them in there. When using said parameter, OctoPrint will attempt to still install them, but if one fails it won't abort the whole attempt.