Forums

Some sort of import error

I uploded my files in the python anywhere page. when i saved and checked the url it showed me something went wrong. After checking the error.log page it shows me

2023-10-26 22:39:10,520: Error running WSGI application
2023-10-26 22:39:10,521: ImportError: cannot import name '_app_ctx_stack' from 'flask' 
(/home/JubileeCell786/.local/lib/python3.10/site-packages/flask/__init__.py)
2023-10-26 22:39:10,521:   File "/var/www/jubileecell786_pythonanywhere_com_wsgi.py", line 16, in <module>
2023-10-26 22:39:10,521:     from main import app as application  # noqa
2023-10-26 22:39:10,521: 
2023-10-26 22:39:10,522:   File "/home/JubileeCell786/mysite/main.py", line 1, in <module>
2023-10-26 22:39:10,522:     from website import create_app
2023-10-26 22:39:10,522: 
2023-10-26 22:39:10,522:   File "/home/JubileeCell786/mysite/website/__init__.py", line 3, in <module>
2023-10-26 22:39:10,522:     from flask_sqlalchemy import SQLAlchemy
2023-10-26 22:39:10,522: 
2023-10-26 22:39:10,522:   File "/usr/local/lib/python3.10/site-packages/flask_sqlalchemy/__init__.py", line 14, in <module>
2023-10-26 22:39:10,523:     from flask import _app_ctx_stack, abort, current_app, request

I tried looking for the file in the files and saw these lines

from __future__ import annotations

import typing as t

from . import json as json
from .app import Flask as Flask
from .blueprints import Blueprint as Blueprint
from .config import Config as Config
from .ctx import after_this_request as after_this_request
from .ctx import copy_current_request_context as copy_current_request_context
from .ctx import has_app_context as has_app_context
from .ctx import has_request_context as has_request_context
from .globals import current_app as current_app
from .globals import g as g
from .globals import request as request
from .globals import session as session
from .helpers import abort as abort
from .helpers import flash as flash
from .helpers import get_flashed_messages as get_flashed_messages
from .helpers import get_template_attribute as get_template_attribute
from .helpers import make_response as make_response
from .helpers import redirect as redirect
from .helpers import send_file as send_file
from .helpers import send_from_directory as send_from_directory
from .helpers import stream_with_context as stream_with_context
from .helpers import url_for as url_for
from .json import jsonify as jsonify
from .signals import appcontext_popped as appcontext_popped
from .signals import appcontext_pushed as appcontext_pushed
from .signals import appcontext_tearing_down as appcontext_tearing_down
from .signals import before_render_template as before_render_template
from .signals import got_request_exception as got_request_exception
from .signals import message_flashed as message_flashed
from .signals import request_finished as request_finished
from .signals import request_started as request_started
from .signals import request_tearing_down as request_tearing_down
from .signals import template_rendered as template_rendered
from .templating import render_template as render_template
from .templating import render_template_string as render_template_string
from .templating import stream_template as stream_template
from .templating import stream_template_string as stream_template_string
from .wrappers import Request as Request
from .wrappers import Response as Response

i tried removing the lines with the error but didnt work.

Which file is that? Removing imports will not necessarily fix the issue, as usually imports are needed for the code to work. Also, if you make changes in your code, you need to reload the web app.