Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flask app in Python constantly showing an error which I cannot understand

import config
from server import app

Config = config.Config()
ipServer = Config.ipServer
portServer = Config.portServer
debug = Config.debug
 
if __name__ == '__main__':
   app.run(debug=debug, host=ipServer, port=portServer)

This is main.py file whenever I run python main.py I get this error which I cannot understand at all, please help me find my mistake.

Traceback (most recent call last):
  File "/home/abledtaha/Projects/upm/upm_server/src/main.py", line 2, in <module>
    from server import app
  File "/home/abledtaha/Projects/upm/upm_server/src/server.py", line 3, in <module>
    from flask import Flask
  File "/home/abledtaha/anaconda3/envs/upm_server/lib/python3.12/site-packages/flask/__init__.py", line 7, in <module>
    from .app import Flask as Flask
  File "/home/abledtaha/anaconda3/envs/upm_server/lib/python3.12/site-packages/flask/app.py", line 27, in <module>
    from . import cli
  File "/home/abledtaha/anaconda3/envs/upm_server/lib/python3.12/site-packages/flask/cli.py", line 17, in <module>
    from .helpers import get_debug_flag
  File "/home/abledtaha/anaconda3/envs/upm_server/lib/python3.12/site-packages/flask/helpers.py", line 14, in <module>
    from werkzeug.urls import url_quote
ImportError: cannot import name 'url_quote' from 'werkzeug.urls' (/home/abledtaha/anaconda3/envs/upm_server/lib/python3.12/site-packages/werkzeug/urls.py). Did you mean: 'unquote'?

It is an old project of mine which I last ran on my Windows about a year ago maybe but have no idea what is going on now even though I did not make any changes.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The error seems to be related to a version mismatch or change in the Flask and Werkzeug libraries. The url_quote function appears to have been removed in newer versions of Werkzeug.

You can try to upgrade Flask:

pip install --upgrade flask

or downgrade Werkzeug:

pip install werkzeug==0.16.0

to see if that resolves the error.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading