Closed I-AM-GROOOOOOT closed 2 years ago
Hi @I-AM-GROOOOOOT. Managing Python versions and environments can be very frustrating so I hope I can help you out a bit!
Just installing Python 3.8 on your Raspberry Pi won't be enough to get OctoPrint to "recognize it." You actually need to create an entirely new Python virtual environment for OctoPrint to run inside. In doing so, you would be creating an entirely new "instance" of OctoPrint, with its own set of plugins and customizations. You can always turn this into the primary instance if you want to by modifying /etc/systemd/system/octoprint.service
to point to your new virtual environment. You will want to use the instructions at the bottom of this page under the section titled "Installing Manually." Make sure to create the virtual environment using the Python 3.8 interpreter you just installed: python3.8 -m venv OctoPrint
.
I'm going to close this issue but feel free to keep commenting if you need more help and I'll respond when I can!
So yes, I saw the first issue (which you've already closed), and assumed that using the "Installing Manually" would fix my issue, but clearly I haven't done it right, as my current Python env is not 3.8. So I copied and used the codes from there, but it hasn't worked fully... did I miss something?
Here are the codes I ran, in order:
python -m venv OctoPrint
OctoPrint/bin/pip install OctoPrint
./OctoPrint/bin/octoprint serve
Those are the codes that are shown on the Installing Manually section, I believe.
Now I don't understand what you mean by "Make sure to create the virtual environment using the Python 3.8 interpreter you just installed: python3.8 -m venv OctoPrint
"
The first command you executed (python -m venv OctoPrint
) uses whatever the default Python interpreter is on your system (presumably Python 3.7.3) to create a new Python virtual environment that matches that version of Python. You can check which interpreter that refers to by running which python
or just running python --version
.
Executing python3.8 -m venv OctoPrint
instead will create the virtual environment using the Python 3.8 interpreter you installed, which is what you want. So if you just run
python3.8 -m venv OctoPrint
. OctoPrint/bin/activate
pip install OctoPrint
octoprint serve
you should have an OctoPrint instance with Python 3.8.
Wow, thanks for the quick reply! So that final code gives this error, saying it traces back to "address already in use"
My assumption is that that means the new 3.8 Python env is basically in conflict with the current env. Is that right? If so, how do I resolve this? Or, is it simply that I need to go to a different instance, and if so, how? Sorry to question so much! I've been using Raspis for some time now, but my knowledge of the whole thing is relatively low... I can figure out basic codes and logically fix things (as I have many a time), but sometimes I get stumped.
So is there no simple way to just update the current Octoprint instance's environment to 3.8? That seems the simplest way to go.
The "address already in use" error indicates that your old OctoPrint server is still running. Try sudo systemctl stop octoprint.service
and then run octoprint serve
again.
You will not want to have two different OctoPrint servers in the long-term. Once you're satisfied that the new OctoPrint instance with Python 3.8 is the one you'd like to stick with:
/etc/systemd/system/octoprint.service
./etc/systemd/system/octoprint.service
on your Raspberry PI to point to your new Python 3.8 virtual environment.
ExecStart=/home/pi/OctoPrint_Python3.10/venv/bin/octoprint serve --host=${HOST} --port=${PORT}
. You will want to change this to suit your setup.sudo systemctl daemon-reload
to reload the modified systemd file.sudo systemctl start octoprint.service
to start the server through systemd and check that everything is working properly.So is there no simple way to just update the current Octoprint instance's environment to 3.8? That seems the simplest way to go.
I am not aware of any way to do this, since OctoPrint is itself a Python package and thus dependent on the Python interpreter that was used to run it.
So I'm assuming to start the other (original) Octoprint instance, I need to simply change out the "stop" part of the first code (sudo systemctl stop octoprint.service
) to "start", right? Now how do I start/stop the new instance? What's the name of the new Octoprint instance? With that, I can use the same code as above mentioned, I think.
Since the original Python 3.7.3 instance is currently registered through systemd, you are correct that you can use systemctl start
and systemctl stop
to start and stop that server.
The new Python 3.8 instance is not currently registered through systemd (to do that you'd use the steps I outlined above, which would swap the two), so you can just use octoprint serve
from within its virtual environment to start it and Ctrl-C
to stop it for now.
Gotcha!! (Maybe) One last question: if I make a backup of my current Octoprint instance, plugins and all, can I use it on the new instance, or is the Python version a block for me in regards to backups?
The "Backup & Restore" feature did work for me, but I know very little about its inner workings so your mileage may vary.
If you hit a wall with that, you could also try a pip freeze
from the original OctoPrint environment, ~/oprint/bin/python -m pip freeze > ~/octoprint_requirements.txt
assuming everything is in the default location. Then you could run pip install -r ~/octoprint_requirements.txt
from the new Python 3.8 environment.
As a last resort, you may need to manually reinstall some plugins.
Alrighty, thanks!! You've been most helpful and very quick to respond. :)
Glad I could help! Please don't hesitate to reach out again if there's anything else you're having trouble with :)
So I've been using Octoprint and Wyze devices for a long time, and this plugin is just perfect for me! But maybe not...
I'm having issues installing it, and I believe it's due to the Python version. I have installed the Python 3.8 to my Pi, but OctoPrint won't recognize it, saying I'm on Python V3.7.3 (see screenshot). Can someone point me to the proper way to install Python 3.8 to my OctoPrint environment? I've been all over the web trying to find ways to update Python, the OctoPrint env, pip, and all sorts of other stuff.
I will also note that my pip version is at 22.0.4, the most recent. IDK if that has much to do with this, but I thought I'd just note that. Thanks in advance for any help!! :)