TypQxQ / kTAMV

Klipper Tool Alignment (using) Machine Vision
GNU General Public License v3.0
70 stars 8 forks source link

kTAMV installed, but service fails to start on reboot #10

Closed OldGuyMeltsPlastic closed 6 months ago

OldGuyMeltsPlastic commented 6 months ago

I am running kTAMV on a Voron Tridex with two toolheads.

After installation, and rebooting my Tridex, I see the following errors when running sudo journalctl -e: Apr 01 13:02:38 gemeaux systemd[1]: kTAMV_server.service: Scheduled restart job, restart counter is at 1. Apr 01 13:02:38 gemeaux systemd[1]: Stopped kTAMV_server.service - Server component for kTAMV. A tool alignment tool for Klipper using machine vision.. Apr 01 13:02:38 gemeaux systemd[1]: Started kTAMV_server.service - Server component for kTAMV. A tool alignment tool for Klipper using machine vision.. Apr 01 13:02:38 gemeaux python[1655]: Traceback (most recent call last): Apr 01 13:02:38 gemeaux python[1655]: File "/home/pi/kTAMV/server/ktamv_server.py", line 3, in <module> Apr 01 13:02:38 gemeaux python[1655]: from flask import Flask, jsonify, request, send_file #, send_from_directory Apr 01 13:02:38 gemeaux python[1655]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Apr 01 13:02:38 gemeaux python[1655]: File "/usr/lib/python3/dist-packages/flask/__init__.py", line 5, in <module> Apr 01 13:02:38 gemeaux python[1655]: from .app import Flask as Flask Apr 01 13:02:38 gemeaux python[1655]: File "/usr/lib/python3/dist-packages/flask/app.py", line 30, in <module> Apr 01 13:02:38 gemeaux python[1655]: from werkzeug.urls import url_quote Apr 01 13:02:38 gemeaux python[1655]: ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/home/pi/.local/lib/python3.11/site-packages/werkzeug/urls.py) Apr 01 13:02:38 gemeaux systemd[1]: kTAMV_server.service: Main process exited, code=exited, status=1/FAILURE Apr 01 13:02:38 gemeaux systemd[1]: kTAMV_server.service: Failed with result 'exit-code'. I am running another server that also uses Flask, but it's using Flask 3.0.0 in a virtual environment container, and I am wondering if that could be causing this error with kTAMV?

TypQxQ commented 6 months ago

Hi!

kTAMV is tested on Raspbian and even though running in a venv, it uses the packages installed in system with apt-get. I tried on a fresh install and it works fine. The versions I got installed are: Flask 1.1.2 Werkzeug 1.0.1 There aperently is a dependency problem between versions newer than the ones supplied with Raspbian like Werkzeug 3.0.

What versions do you run on the system?

OldGuyMeltsPlastic commented 6 months ago

Thanks for your response!

Here's the information about my environment:

pi@gemeaux:~ $ uname -a
Linux gemeaux 6.6.22-v8-16k+ #1747 SMP PREEMPT Wed Mar 27 17:06:56 GMT 2024 aarch64 GNU/Linux
pi@gemeaux:~ $ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
pi@gemeaux:~ $ sudo apt-get install python3-flask
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-flask is already the newest version (2.2.2-3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@gemeaux:~ $ sudo apt-get install python3-werkzeug
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-werkzeug is already the newest version (2.2.2-3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@gemeaux:~ $ sudo apt-get install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3 is already the newest version (3.11.2-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
TypQxQ commented 6 months ago

It seems that the MainsailOS installs a older version: pi@qtc:~/kTAMV/server $ uname -a Linux qtc 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux pi@qtc:~/kTAMV/server $ cat /etc/os-release PRETTY_NAME="Debian GNU/Linux 11 (bullseye)" NAME="Debian GNU/Linux" VERSION_ID="11" VERSION="11 (bullseye)" VERSION_CODENAME=bullseye ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/" pi@qtc:~/kTAMV/server $ pi@qtc:~/kTAMV/server $ sudo apt-get install python3-flask [sudo] password for pi: Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-flask is already the newest version (1.1.2-2+deb11u1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. pi@qtc:~/kTAMV/server $ sudo apt-get install python3-werkzeug Reading package lists... Done Building dependency tree... Done Reading state information... Done python3-werkzeug is already the newest version (1.0.1+dfsg1-2+deb11u1). python3-werkzeug set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. pi@qtc:~/kTAMV/server $ sudo apt-get install python3 Reading package lists... Done Building dependency tree... Done Reading state information... Done python3 is already the newest version (3.9.2-3). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. pi@qtc:~/kTAMV/server $

I will try to upgrade my system and check again.

TypQxQ commented 6 months ago

I installed a fresh Raspbery Pi Lite, updated all and installed kTAMV. It works fine for me so it's not that. I will try to find out if I can find more information on your problem:

pi@qtc:~ $ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
pi@qtc:~ $ sudo apt-get install python3-flask
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-flask is already the newest version (2.2.2-3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@qtc:~ $ sudo apt-get install python3-werkzeug
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-werkzeug is already the newest version (2.2.2-3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
pi@qtc:~ $ sudo apt-get install python3
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3 is already the newest version (3.11.2-1+b1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

image

TypQxQ commented 6 months ago

Can you please doublecheck that the venv uses the right versions:

pi@qtc:~/ktamv-env/bin $ pip list | grep Werkzeug
Werkzeug           2.2.2
pi@qtc:~/ktamv-env/bin $ pip list | grep Flask
Flask              2.2.2

This is the reason I can find: https://stackoverflow.com/questions/77213053/why-did-flask-start-failing-with-importerror-cannot-import-name-url-quote-fr

One can install specific versions to the venv to override the system installed ones if so: https://stackoverflow.com/questions/12079607/make-virtualenv-inherit-specific-packages-from-your-global-site-packages

Please check if this helps 😃

OldGuyMeltsPlastic commented 6 months ago

I have:

pi@gemeaux:~/ktamv-env/bin $ pip list | grep Werkzeug
Werkzeug           3.0.1
pi@gemeaux:~/ktamv-env/bin $ pip list | grep Flask
Flask              2.2.2
OldGuyMeltsPlastic commented 6 months ago

Can you please doublecheck that the venv uses the right versions:

pi@qtc:~/ktamv-env/bin $ pip list | grep Werkzeug
Werkzeug           2.2.2
pi@qtc:~/ktamv-env/bin $ pip list | grep Flask
Flask              2.2.2

This is the reason I can find: https://stackoverflow.com/questions/77213053/why-did-flask-start-failing-with-importerror-cannot-import-name-url-quote-fr

One can install specific versions to the venv to override the system installed ones if so: https://stackoverflow.com/questions/12079607/make-virtualenv-inherit-specific-packages-from-your-global-site-packages

Please check if this helps 😃

One possible solution suggests installing the older version of Werkzeug into the venv, but didn't provide instructions on how to do that.

The other one suggested adding a line in requirements.txt to specify the version to be used, but I don't see a requirements.txt in the ktamv-env folder structure.

Any additional guidance with either solution would be greatly appreciated.

TypQxQ commented 6 months ago

I will try to get a working commandline install for you when I get home later./Andrei2 apr. 2024 kl. 18:17 skrev OldGuyMeltsPlastic @.***>:

Can you please doublecheck that the venv uses the right versions: @.***:~/ktamv-env/bin $ pip list | grep Werkzeug Werkzeug 2.2.2

@.***:~/ktamv-env/bin $ pip list | grep Flask Flask 2.2.2

This is the reason I can find: https://stackoverflow.com/questions/77213053/why-did-flask-start-failing-with-importerror-cannot-import-name-url-quote-fr One can install specific versions to the venv to override the system installed ones if so: https://stackoverflow.com/questions/12079607/make-virtualenv-inherit-specific-packages-from-your-global-site-packages Please check if this helps 😃

One possible solution suggests installing the older version of Werkzeug into the venv, but didn't provide instructions on how to do that. The other one suggested adding a line in requirements.txt to specify the version to be used, but I don't see a requirements.txt in the ktamv-env folder structure. Any additional guidance with either solution would be greatly appreciated.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

OldGuyMeltsPlastic commented 6 months ago

Thanks again for your help!

TypQxQ commented 6 months ago

This command should install the right version inside the right venv;

~/ktamv-env/bin/pip install --force-reinstall "Werkzeug==2.2.2"

Tested on my system and it works here.

OldGuyMeltsPlastic commented 6 months ago

I opted to go the other route, and upgraded Flask to 3.0.2. kTAMV server is now running fine with this in combination with Werkzeug 3.0.1.

Thanks again for your guidance!

TypQxQ commented 6 months ago

Happy it worked out and good to know that it works with newer versions too :)