Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation Issues, Clarification Requested #5

Closed
I-AM-GROOOOOOT opened this issue Mar 23, 2022 · 13 comments
Closed

Installation Issues, Clarification Requested #5

I-AM-GROOOOOOT opened this issue Mar 23, 2022 · 13 comments
Assignees

Comments

@I-AM-GROOOOOOT
Copy link

I-AM-GROOOOOOT commented Mar 23, 2022

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!! :)
image

@eshapiro42
Copy link
Owner

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!

@eshapiro42 eshapiro42 self-assigned this Mar 23, 2022
@I-AM-GROOOOOOT
Copy link
Author

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"

@eshapiro42
Copy link
Owner

eshapiro42 commented Mar 23, 2022

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.

@I-AM-GROOOOOOT
Copy link
Author

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.
image

@I-AM-GROOOOOOT
Copy link
Author

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.

@eshapiro42
Copy link
Owner

eshapiro42 commented Mar 23, 2022

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:

  1. Make a backup of /etc/systemd/system/octoprint.service.
  2. Modify /etc/systemd/system/octoprint.service on your Raspberry PI to point to your new Python 3.8 virtual environment.
    • For reference, mine contains the line ExecStart=/home/pi/OctoPrint_Python3.10/venv/bin/octoprint serve --host=${HOST} --port=${PORT}. You will want to change this to suit your setup.
  3. Run sudo systemctl daemon-reload to reload the modified systemd file.
  4. Run sudo systemctl start octoprint.service to start the server through systemd and check that everything is working properly.

@eshapiro42
Copy link
Owner

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.

@I-AM-GROOOOOOT
Copy link
Author

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.

@eshapiro42
Copy link
Owner

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.

@I-AM-GROOOOOOT
Copy link
Author

I-AM-GROOOOOOT commented Mar 23, 2022

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?

@eshapiro42
Copy link
Owner

eshapiro42 commented Mar 23, 2022

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.

@I-AM-GROOOOOOT
Copy link
Author

Alrighty, thanks!! You've been most helpful and very quick to respond. :)

@eshapiro42
Copy link
Owner

Glad I could help! Please don't hesitate to reach out again if there's anything else you're having trouble with :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants