zalsaeed / cgav

Certificate Generation and Verification
GNU General Public License v3.0
3 stars 1 forks source link

Flask Application ImportError Issue #6

Closed wesamhamad closed 5 months ago

wesamhamad commented 8 months ago

Description

I encountered an ImportError while trying to run my Flask application inside a Docker container. The error traceback indicates an issue with the import of 'url_decode' from 'werkzeug.urls'. Here are the details:

Error Traceback:

Traceback (most recent call last):
  File "/root/src/flask-website/app.py", line 3, in <module>
    from flask_login import UserMixin, login_user, LoginManager, login_required, logout_user, current_user
  File "/usr/local/lib/python3.9/site-packages/flask_login/__init__.py", line 12, in <module>
    from .login_manager import LoginManager
  File "/usr/local/lib/python3.9/site-packages/flask_login/login_manager.py", line 35, in <module>
    from .utils import _create_identifier
  File "/usr/local/lib/python3.9/site-packages/flask_login/utils.py", line 14, in <module>
    from werkzeug.urls import url_decode
ImportError: cannot import name 'url_decode' from 'werkzeug.urls' (/usr/local/lib/python3.9/site-packages/werkzeug/urls.py)

Additional Information:

This issue arises after encountering multiple dependency conflicts during the Docker image build process. Specifically, conflicts with Click, Jinja2, and Werkzeug versions were identified. The original issue report with details on the dependency conflicts is here.

Please note that changing Flask to Flask==2.3.3 triggered this problem.

wesamhamad commented 8 months ago

Temporary Resolution Applied, but Flask Version Still Unspecified

I have applied a temporary resolution to address the dependency conflict. The specific versions have been changed in requirements.txt to resolve the conflict:


Flask
click==8.1.2  # Changed to specific version to resolve conflict
Jinja2==3.1.2  # Changed to specific version to resolve conflict
Werkzeug==2.3.7  # Changed to specific version to resolve conflict
zalsaeed commented 8 months ago

If changing flask==2.3.3 to flask it works, then it means we are pulling the latest version of flask (which is 3.0.0). why don't you try flask==3.0.0?

wesamhamad commented 8 months ago

I've checked my Flask version using pip show Flask, and it confirms that I'm currently on version 2.3.3, so I used it. However, I also attempted flask==3.0.0 in the requirements.txt. Unfortunately, it resulted in a similar conflict issue.

Dependency Conflict with Flask==3.0.0

Description:

I encountered a dependency conflict while trying to install the dependencies for Flask version 3.0.0. The conflicts arise with the following packages and their versions:

Then Fixed by Change requirements.txt:

Flask==3.0.0
click>=8.1.2 
Werkzeug>=3.0.0 

After Running app.py

I encountered the following error:

Traceback (most recent call last):
  File "/root/src/flask-website/app.py", line 2, in <module>
    from flask_sqlalchemy import SQLAlchemy
  File "/usr/local/lib/python3.9/site-packages/flask_sqlalchemy/__init__.py", line 14, in <module>
    from flask import _app_ctx_stack, abort, current_app, request
ImportError: cannot import name '_app_ctx_stack' from 'flask' (/usr/local/lib/python3.9/site-packages/flask/__init__.py)

I'll investigate this issue further and provide updates as soon as possible.

If changing flask==2.3.3 to flask it works, then it means we are pulling the latest version of flask (which is 3.0.0). why don't you try flask==3.0.0?

wesamhamad commented 5 months ago

It appears that the same error persists even after commit number 7ae125515b46715caf62b6e3abac59b9443c7335.

wesamhamad commented 5 months ago

Solution:

Flask==2.0.2  #effectively fixed the issue