muammar/mkchromecast

Error with start

yandex8 opened this issue · 2 comments

Hi, the problem when starting mkchromecast
, I tried to deal with
/home/minimal/.local/lib/python3.8/site-packages/markupsafe/init.py
But nothing works out.

./mkchromecast
Mkchromecast v0.3.9
Creating Pulseaudio Sink...
Open Pavucontrol and Select the Mkchromecast Sink.
Starting Local Streaming Server
Traceback (most recent call last):
File "./mkchromecast", line 289, in
CastProcess(mkcc).run()
File "./mkchromecast", line 69, in run
self.start_audiocast()
File "./mkchromecast", line 94, in start_audiocast
import mkchromecast.audio
File "/media/mkchromecast/mkchromecast/bin/../mkchromecast/audio.py", line 16, in
from mkchromecast import pipeline_builder
File "/media/mkchromecast/mkchromecast/bin/../mkchromecast/pipeline_builder.py", line 11, in
from mkchromecast import stream_infra
File "/media/mkchromecast/mkchromecast/bin/../mkchromecast/stream_infra.py", line 4, in
import flask
File "/usr/lib/python3/dist-packages/flask/init.py", line 14, in
from jinja2 import escape
File "/usr/lib/python3/dist-packages/jinja2/init.py", line 33, in
from jinja2.environment import Environment, Template
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 15, in
from jinja2 import nodes
File "/usr/lib/python3/dist-packages/jinja2/nodes.py", line 23, in
from jinja2.utils import Markup
File "/usr/lib/python3/dist-packages/jinja2/utils.py", line 676, in
from markupsafe import Markup, escape, soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/home/mini/.local/lib/python3.8/site-packages/markupsafe/init.py)
Killed

I also suggested installing the markupsafe version==2.0.1 in requirements.txt
but it didn't work because
werkzeug 2.2.1 requires MarkupSafe>=2.1.1

after that, I tried to specify in requirements.txt werkzeug==2.1.2,
but also nothing worked
File "/usr/lib/python3/dist-packages/flask/init.py", line 21, in
from .app import Flask
File "/usr/lib/python3/dist-packages/flask/app.py", line 32, in
from werkzeug.wrappers import BaseResponse
ImportError: cannot import name 'BaseResponse' from 'werkzeug.wrappers' (/home/mini/.local/lib/python3.8/site-packages/werkzeug/wrappers/init.py)
Killed

xsdg commented

According to https://stackoverflow.com/a/73726848 , this is a compatibility issue between jinja2 and markupsafe. The recommendation from the answer linked above us to upgrade jinja2.

Beyond that, python 3.8 is pretty old (Debian is shipping python 3.11 in stable these days). So that might be something else to look into.

Marking this as closed, since it's not an mkchromecast issue.

The root cause with your issue stems from a dependency management conflict between two software ecosystems. According to the error message, your 'werkzeug' was installed using 'pip' at the path /home/mini/.local/lib/python3.8/site-packages/werkzeug. The 'flask' that depends on it was installed using 'apt' at the path /usr/lib/python3/dist-packages/flask. The versions of the two are not compatible. In fact, there is a version of 'werkzeug' in the system that 'flask' correctly depends on, but the Python interpreter prioritizes the 'werkzeug' installed by 'pip', leading to this issue. There are typically two solutions to this problem: (1) Use 'pip' to uninstall werkzeug, and then reinstall it using 'apt', or uninstall 'flask' using 'apt' and reinstall it using 'pip'. (2) Use Python's imp module to customize the path and import the 'werkzeug' from the 'apt' path before importing 'flask'. An example is as follows:

import imp
path = ['/usr/lib/python3/dist-packages']
fp, pathname, description = imp.find_module('werkzeug', path)
imp.load_module("werkzeug", fp, pathname, description)

Hope my diagnosis is helpful to you! @yandex8