MxChartDB - ModuleNotFoundError: No module named 'flask'

Post Reply
feuersee
Posts: 34
Joined: 07 Jan 2016 01:53

MxChartDB - ModuleNotFoundError: No module named 'flask'

Post by feuersee »

Hallo,

ich versuche MxChartDB1 zu installieren und scheitere. Hilft die Ausgabe zur Eingrenzung des Fehlers?

Requirement already satisfied: MarkupSafe>=2.0 in /home/pi/.local/lib/python3.9/site-packages (from Jinja2>=3.1.2->flask) (2.1.3)
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'flask'
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: flask-cors in /home/pi/.local/lib/python3.9/site-packages (4.0.0)
Requirement already satisfied: Flask>=0.9 in /home/pi/.local/lib/python3.9/site-packages (from flask-cors) (3.0.0)
Requirement already satisfied: Werkzeug>=3.0.0 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (3.0.0)
Requirement already satisfied: Jinja2>=3.1.2 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (3.1.2)
Requirement already satisfied: itsdangerous>=2.1.2 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (2.1.2)
Requirement already satisfied: click>=8.1.3 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (8.1.7)
Requirement already satisfied: blinker>=1.6.2 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (1.6.3)
Requirement already satisfied: importlib-metadata>=3.6.0 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (6.8.0)
Requirement already satisfied: zipp>=0.5 in /home/pi/.local/lib/python3.9/site-packages (from importlib-metadata>=3.6.0->Flask>=0.9->flask-cors) (3.17.0)
Requirement already satisfied: MarkupSafe>=2.0 in /home/pi/.local/lib/python3.9/site-packages (from Jinja2>=3.1.2->Flask>=0.9->flask-cors) (2.1.3)

Viele Grüße,
Stephan
piet66
Posts: 268
Joined: 04 Feb 2017 17:00

Re: MxChartDB - ModuleNotFoundError: No module named 'flask'

Post by piet66 »

Hallo Stephan,
wann kommen diese Meldungen, bei install_sqlite.bash oder bei MxChartDB_API.bash?

Am wahrscheinlichsten sind entweder ungenügende Linux-Benutzerrechte oder falsche Pfade.
Sag doch bitte, was du genau gemacht hast, mit welchen Pfaden und welche Rechte die Ordner benötigen. Welches Betriebssystem benutzt du?
Raspberry Pi 3 Model B Rev 1.2
Raspbian GNU/Linux 10 (buster, 32bit)
RaZberry by Z-Wave.Me ZW0700 7.20.00 07.38/1766938484 1025/257
Z-Way version v4.1.2 from 2023-10-18 03:34:26 +0300
feuersee
Posts: 34
Joined: 07 Jan 2016 01:53

Re: MxChartDB - ModuleNotFoundError: No module named 'flask'

Post by feuersee »

Hallo,
ich habe install_sqlite.bash mit dem User pi auf Basis der Installation des Fullimages https://storage.z-wave.me/z-way-server/ vorgenommen. Ich bin in der Zwischenzeit auf v4.1.2-wb1 (über apt-get ist mein System mit allen aktuellen Patches gepatched). Die Installation habe ich auf /media/ZWay_USB (USB Stick /dev/sda1 -> /media/ZWay_USB) gemacht. Via console habe ich auch mit dem User pi pip3 install flask durchgeführt. python3 -V liefert Python 3.9.2.

Lasse ich dein Script erneut durchlaufen exkl. exit und inkl. Tests ist das die Ausgabe:

./install_sqlite.bash
mkdir: cannot create directory ‘sqliteDB’: File exists
mkdir: cannot create directory ‘python_env’: File exists
mkdir: cannot create directory ‘log’: File exists
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
sqlite3 is already the newest version (3.34.1-3).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Python 3.9.2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-pip is already the newest version (20.3.4-4+rpt1+deb11u1).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'python-dev-is-python2' instead of 'python-dev'
build-essential is already the newest version (12.9).
libffi-dev is already the newest version (3.3-6).
python-dev-is-python2 is already the newest version (2.7.18-9).
libssl-dev is already the newest version (1.1.1w-0+deb11u1+rpt1).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-venv is already the newest version (3.9.2-3).
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: flask in /home/pi/.local/lib/python3.9/site-packages (3.0.0)
Requirement already satisfied: Werkzeug>=3.0.0 in /home/pi/.local/lib/python3.9/site-packages (from flask) (3.0.0)
Requirement already satisfied: Jinja2>=3.1.2 in /home/pi/.local/lib/python3.9/site-packages (from flask) (3.1.2)
Requirement already satisfied: itsdangerous>=2.1.2 in /home/pi/.local/lib/python3.9/site-packages (from flask) (2.1.2)
Requirement already satisfied: click>=8.1.3 in /home/pi/.local/lib/python3.9/site-packages (from flask) (8.1.7)
Requirement already satisfied: blinker>=1.6.2 in /home/pi/.local/lib/python3.9/site-packages (from flask) (1.6.3)
Requirement already satisfied: importlib-metadata>=3.6.0 in /home/pi/.local/lib/python3.9/site-packages (from flask) (6.8.0)
Requirement already satisfied: zipp>=0.5 in /home/pi/.local/lib/python3.9/site-packages (from importlib-metadata>=3.6.0->flask) (3.17.0)
Requirement already satisfied: MarkupSafe>=2.0 in /home/pi/.local/lib/python3.9/site-packages (from Jinja2>=3.1.2->flask) (2.1.3)
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'flask'
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: flask-cors in /home/pi/.local/lib/python3.9/site-packages (4.0.0)
Requirement already satisfied: Flask>=0.9 in /home/pi/.local/lib/python3.9/site-packages (from flask-cors) (3.0.0)
Requirement already satisfied: Werkzeug>=3.0.0 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (3.0.0)
Requirement already satisfied: Jinja2>=3.1.2 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (3.1.2)
Requirement already satisfied: itsdangerous>=2.1.2 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (2.1.2)
Requirement already satisfied: click>=8.1.3 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (8.1.7)
Requirement already satisfied: blinker>=1.6.2 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (1.6.3)
Requirement already satisfied: importlib-metadata>=3.6.0 in /home/pi/.local/lib/python3.9/site-packages (from Flask>=0.9->flask-cors) (6.8.0)
Requirement already satisfied: zipp>=0.5 in /home/pi/.local/lib/python3.9/site-packages (from importlib-metadata>=3.6.0->Flask>=0.9->flask-cors) (3.17.0)
Requirement already satisfied: MarkupSafe>=2.0 in /home/pi/.local/lib/python3.9/site-packages (from Jinja2>=3.1.2->Flask>=0.9->flask-cors) (2.1.3)
blinker==1.6.3
cachetools==4.2.4
certifi==2020.6.20
chardet==4.0.0
click==8.1.7
colorzero==1.1
distro==1.5.0
Flask==3.0.0
Flask-Cors==4.0.0
google-auth==2.3.3
google-auth-oauthlib==0.4.6
gpiozero==1.6.2
gspread==5.0.0
httplib2==0.20.2
idna==2.10
importlib-metadata==6.8.0
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
oauth2client==4.1.3
oauthlib==3.1.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pyparsing==3.0.6
python-apt==2.2.1
requests==2.25.1
requests-oauthlib==1.3.0
RPi.GPIO==0.7.0
rsa==4.8
six==1.16.0
spidev==3.5
ssh-import-id==5.10
urllib3==1.26.5
Werkzeug==3.0.0
zipp==3.17.0
Hello, World!
Traceback (most recent call last):
File "/home/pi/.local/bin/flask", line 8, in <module>
sys.exit(main())
File "/home/pi/.local/lib/python3.9/site-packages/flask/cli.py", line 1064, in main
cli.main()
File "/home/pi/.local/lib/python3.9/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/pi/.local/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/pi/.local/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/pi/.local/lib/python3.9/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/click/decorators.py", line 92, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/pi/.local/lib/python3.9/site-packages/flask/cli.py", line 912, in run_command
raise e from None
File "/home/pi/.local/lib/python3.9/site-packages/flask/cli.py", line 898, in run_command
app = info.load_app()
File "/home/pi/.local/lib/python3.9/site-packages/flask/cli.py", line 309, in load_app
app = locate_app(import_name, name)
File "/home/pi/.local/lib/python3.9/site-packages/flask/cli.py", line 219, in locate_app
__import__(module_name)
File "/media/ZWay_USB/python_env/hello.py", line 1
from flask import Flask
IndentationError: unexpected indent

---------------------------------------------------------------------------------------------------
Rechte auf site-packages

~/.local/lib/python3.9/site-packages $ ls -l
total 88
drwxrwxrwx 3 pi pi 4096 Oct 14 17:18 blinker
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 blinker-1.6.3.dist-info
drwxrwxrwx 3 pi pi 4096 Oct 14 17:18 click
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 click-8.1.7.dist-info
drwxrwxrwx 5 pi pi 4096 Oct 14 17:18 flask
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 flask-3.0.0.dist-info
drwxr-xr-x 3 pi pi 4096 Oct 15 11:26 flask_cors
drwxr-xr-x 2 pi pi 4096 Oct 15 11:26 Flask_Cors-4.0.0.dist-info
drwxrwxrwx 3 pi pi 4096 Oct 14 17:18 importlib_metadata
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 importlib_metadata-6.8.0.dist-info
drwxrwxrwx 3 pi pi 4096 Oct 14 17:18 itsdangerous
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 itsdangerous-2.1.2.dist-info
drwxrwxrwx 3 pi pi 4096 Oct 14 17:18 jinja2
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 Jinja2-3.1.2.dist-info
drwxrwxrwx 3 pi pi 4096 Oct 14 17:18 markupsafe
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 MarkupSafe-2.1.3.dist-info
drwxr-xr-x 5 pi pi 4096 Oct 26 17:59 pip
drwxr-xr-x 2 pi pi 4096 Oct 26 18:00 pip-23.3.1.dist-info
drwxrwxrwx 9 pi pi 4096 Oct 14 17:18 werkzeug
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 werkzeug-3.0.0.dist-info
drwxrwxrwx 3 pi pi 4096 Oct 14 17:18 zipp
drwxrwxrwx 2 pi pi 4096 Oct 14 17:18 zipp-3.17.0.dist-info


VG Stephan
piet66
Posts: 268
Joined: 04 Feb 2017 17:00

Re: MxChartDB - ModuleNotFoundError: No module named 'flask'

Post by piet66 »

Hallo Stephan,
du hast das so gemacht, wie ich es vorgesehen habe. Das grenzt die Möglichkeiten ein.

Ich habe es auf einem neuen System (Raspbian bullseye von raspberrypi.com, alle Updates) probeweise installiert. Bei mir läuft es ohne Fehler. Die ZWay Version ist uninteressant, da nicht betroffen.
Anbei mein Log zum Vergleich.

Zum Testabschnitt:
Aufgrund eines dummen Fehlers funktioniert der Test nicht, sondern bringt nur nutzlose Fehlermeldungen. Du kannst alles nach 'Traceback (most recent call last):' ignorieren. Leider sind die Fehlermeldungen von Python oft sehr merkwürdig. Am besten löschst du den ganzen Abschnitt. Der Test ist ohne zusätzliche Erklärung sowieso nicht nützlich.

Bleibt noch die Fehlermeldung:
Defaulting to user installation because normal site-packages is not writeable
Diese Meldung deutet darauf hin, dass der Ordner /media/ZWay_USB/python_env nicht beschreibbar ist.
Zur Erklärung: Die API benötigt einige zusätzliche Python-Module. Diese sollen lokal in diesem Verzeichnis, Unterverzeichnis rest_api installiert werden. Das ist nicht zwingend, wird jedoch empfohlen. Kann Python auf dieses Verzeichnis nicht zugreifen, so installiert es die Module woanders, hier in /home/pi/.

Du müsstest herausfinden, warum dieses Verzeichnis nicht beschreibbar ist. Du benutzt doch die letzte MxChartDB Version? Gerade bezüglich der Rechte habe ich mal was geändert.

Diese Rechte funktionieren bei mir:
ls -l / | grep media
drwxr-xr-x 3 root root 4096 Feb 26 2022 media

ls -l /media | grep ZWay_USB
drwxr-xr-x 16 pi pi 4096 Jul 28 13:14 ZWay_USB

ls -l /media/ZWay_USB
drwxrwxrwx 2 pi pi 4096 Oct 28 12:50 log
drwxrwxrwx 4 pi pi 4096 Oct 29 10:51 python_env
drwxrwxrwx 3 pi pi 4096 Oct 28 12:50 sqliteDB

ls -l /media/ZWay_USB/python_env/
total 16
drwxrwxrwx 2 pi pi 4096 Oct 29 10:51 __pycache__
-rw-r--r-- 1 pi pi 102 Oct 29 10:51 hello.py
-rw-rw-rw- 1 pi pi 23 Oct 29 10:17 hello_world.py
drwxrwxrwx 6 pi pi 4096 Oct 28 11:27 rest_api
Attachments
install_sqlite.bash.log.zip
(1.08 KiB) Downloaded 485 times
Raspberry Pi 3 Model B Rev 1.2
Raspbian GNU/Linux 10 (buster, 32bit)
RaZberry by Z-Wave.Me ZW0700 7.20.00 07.38/1766938484 1025/257
Z-Way version v4.1.2 from 2023-10-18 03:34:26 +0300
feuersee
Posts: 34
Joined: 07 Jan 2016 01:53

Re: MxChartDB - ModuleNotFoundError: No module named 'flask'

Post by feuersee »

Habe fertig :-)
System auf Bullseye neu aufgesetzt und alles neu Installiert - jetzt sehe ich einen schönen Graphen. DANKE!
VG Stephan :D
Post Reply