Closed KKdev15 closed 9 months ago
I was able to solve the bug.
Install Jinja==3.1.0 and flask==2.2.0 As reported by pip when installing an old version of Jinja:
mmpm 4.1.0 requires flask>=2.2.0, but you have flask 1.1.2 which is incompatible.
mmpm 4.1.0 requires jinja2>=3.1.0, but you have jinja2 3.0.3 which is incompatible.
Shell commands:
python3 -m pip install Jinja2==3.1.0
python3 -m pip install flask==2.2.0
After this I got another error in the mmpm.api logs:
[2024-01-14 19:53:33 +0100] [1630] [INFO] Worker exiting (pid: 1630)
[2024-01-14 19:53:33 +0100] [1629] [ERROR] Worker (pid:1630) exited with code 3
[2024-01-14 19:53:33 +0100] [1629] [ERROR] Shutting down: Master
[2024-01-14 19:53:33 +0100] [1629] [ERROR] Reason: Worker failed to boot.
[2024-01-14 19:53:34 +0100] [1631] [INFO] Starting gunicorn 21.2.0
[2024-01-14 19:53:34 +0100] [1631] [INFO] Listening at: http://0.0.0.0:7891 (1631)
[2024-01-14 19:53:34 +0100] [1631] [INFO] Using worker: gevent
[2024-01-14 19:53:34 +0100] [1632] [INFO] Booting worker with pid: 1632
[2024-01-14 19:53:38 +0100] [1632] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/arbiter.py", line 609, in spawn_worker
worker.init_process()
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/workers/ggevent.py", line 147, in init_process
super().init_process()
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
self.load_wsgi()
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
return self.load_wsgiapp()
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/pi/.local/lib/python3.9/site-packages/gunicorn/util.py", line 371, in import_app
mod = importlib.import_module(module)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/pi/.local/lib/python3.9/site-packages/mmpm/wsgi.py", line 28, in <module>
from mmpm.api.entrypoint import app
File "/home/pi/.local/lib/python3.9/site-packages/mmpm/api/entrypoint.py", line 8, in <module>
from flask import Flask, Response
File "/home/pi/.local/lib/python3.9/site-packages/flask/__init__.py", line 5, in <module>
from .app import Flask as Flask
File "/home/pi/.local/lib/python3.9/site-packages/flask/app.py", line 29, in <module>
from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/home/pi/.local/lib/python3.9/site-packages/werkzeug/urls.py)
I could solve this by installing an old version of Werkzeug: https://stackoverflow.com/questions/77213053/why-did-flask-start-failing-with-importerror-cannot-import-name-url-quote-fr
python3 -m pip install Werkzeug==2.2.2
Maybe it would make sense to specify the package-dependencies more strictly in the requirements.txt of the mmpm Python module. This way incompatibilities like that should not be a problem.
@KKdev15 what version of mmpm
do you have installed? Are you on the latest 4.1.0
?
@KKdev15 also, I'm unsure of how you have flask
version 1.1.2
installed, with MMPM operating considering the dependencies within the pyproject.toml
are:
dependencies = [
"Flask-Cors>=3.0.8",
"argcomplete>=2.0.0",
"argparse>=1.4",
"beautifulsoup4>=4.11.1",
"colorama>=0.4.3",
"flask-socketio>=5.3.2",
"flask>=2.2.0",
"gevent>=23.9.1",
"gunicorn>=20.1.0",
"jinja2>=3.1.0",
"pygments>=2.12.0",
"python-socketio[client]>=5.7.0",
"requests>=2.28.0",
"yaspin>=2.3.0",
"pip>=23.3.1",
"gitpython>=3.1.40",
"gevent-websocket>=0.10.1",
"prompt-toolkit>=3.0.43",
"importlib_resources; python_version<'3.9'",
]
@KKdev15 what version of
mmpm
do you have installed? Are you on the latest4.1.0
?
@KKdev15 can you provide the version of mmpm you have installed?
@KKdev15 what version of
mmpm
do you have installed? Are you on the latest4.1.0
?@KKdev15 can you provide the version of mmpm you have installed?
@Bee-Mar I have installed the latest version (4.1.0) of mmpm.
I guess the problem was, that I also have the plugin MMM-FastNotes installed. It's dependencies (flask == 1.1.2) are conflicting with the dependencies of mmpm.
Anyway MMM-FastNotes seems to work with the mmpm dependencies as well...
A general question from my side: Is it possible to install different versions of the same package to make sure, that each package has exactly the dependencies it requires? I'm not a Node.js expert, but maybe there is something like venvs in Python?
@KKdev15 ah, well that's not something I expected. Yep, python has virtual environments. You could install mmpm
using a virtualenv if you'd like. You'd basically do the following to get it setup:
python3 -m venv venv # creates a virtualenv named 'venv'
source venv/bin/activate
python3 -m pip install mmpm
You'd have run source venv/bin/activate
prior to using the mmpm
CLI, or you could alias it to make it easier. The installation of the UI will pickup the correct python path even if you use a virtualenv.
Another option is to use pipx
https://github.com/pypa/pipx. That handles the virtualenv creation for you and makes an alias so you don't need to do anything special other than run the CLI like you normally would:
python3 -m pip install pipx
pipx install mmpm
Then just run mmpm
from terminal.
Something else that could be interesting from my end is detecting if the module being installed has python requirements and prompting the user if they want to setup the module in a virtualenv and having mmpm handle that so things are isolated.
@KKdev15 one issue with that module is they made the requirements too strict. Requiring version numbers with ==
hamstrings anyone else installing the same dependency. It's typically a very bad idea to specify dependencies like that unless you're running the application in a container or environment you know won't conflict with anything else.
@KKdev15 in short, for simplicity sake, I'd recommend the following:
python3 -m pip uninstall mmpm
python3 -m pip install pipx
pipx install mmpm
Then go about things how you normally would. The should resolve the issue.
@KKdev15 I'm going to close this issue since the problem was related to another MagicMirror module. If you're still having issues feel free to respond in this thread or email me.
@Bee-Mar Hi, I've had the same issue after installing FastNotes, and I've followed your code block, but it hasn't helped!
do you have a suggestion?
Additional: HTML inspector shows CORS is being blocked.
How do I fix this?
Describe the Bug
Is this an issue with the CLI or GUI? GUI
Is this something that should be put in the Wiki? NO
A clear and concise description of what the bug is.
To Reproduce Steps to reproduce the behavior:
Expected behavior I expect to see modules that are available for install in Marketplace and the config files in the Config Editor
Screenshots
Operating System, Python3 Version, and Web Browser\ (Please complete the following information)
output from
cat /etc/os-release
output from
python3 --version
Python 3.9.2Web Browser (firefox, chrome, safari, chromium, etc) Chrome
MMPM Environment Settings
mmpm env
MMPM Log Files
Download MMPM log files
within the Control Center of the GUI or from themmpm log --zip
mmpm-logs-2024-1-14.zipMagicMirror Config
config.js
Additional Information From the error shown in the Screenshots, I assumed, that the error war part of the mmpm.api process started by pm2. Therefore I checked the logs and found the following error repeating constantly:
From this Stackoverflow issue, I figured out, that maybe the used version of Flask and jinja don't match: https://stackoverflow.com/questions/71718167/importerror-cannot-import-name-escape-from-jinja2
Is this a general dependency problem in mmpm or is this just on my Raspi? If it is just on my Raspi, which version of Flask and jinja do I need and how do I install them into the correct place? Are Flask and jinja installed globally?
Thanks!
EDIT These are the moduled installed on my Raspi (Flask = 1.1.2 and Jinja2 = 3.1.3):