techwithtim / Flask-Web-App-Tutorial

Code for the note storing flask web app made during a YouTube video.
918 stars 1.01k forks source link

Could Not Import 'App' #110

Closed DEMeyers closed 1 year ago

DEMeyers commented 1 year ago

I read the 53 current issues. I did make the change in the init.py for the function def create_database(app): I still get the above error. I am using Visual Studio.

Here is my test messages.

This run is with debug.

'c:\Users\Dan.vscode\extensions\ms-python.python-2023.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '53234' '--' '-m' 'flas 'run' '--no-debugger' '--no-reload' Usage: python -m flask run [OPTIONS] Try 'python -m flask run --help' for help.

Error: Could not import 'app'.

This run is without debug

\website\models.py:11: SAWarning: Can't validate argument 'primary_Key'; can't locate any SQLAlchemy dialect named 'primary' id = db.Column(db.Integer, primary_Key=True) Traceback (most recent call last): File "c:\Users\Dan\Desktop\FLASK WEB APP TUTORIAL\main.py", line 11, in
app = create_app() File "c:\Users\Dan\Desktop\FLASK WEB APP TUTORIAL\website__init.py", line 20, in create_app from .views import views File "c:\Users\Dan\Desktop\FLASK WEB APP TUTORIAL\website\views.py", line 3, in from .models import Note File "c:\Users\Dan\Desktop\FLASK WEB APP TUTORIAL\website\models.py", line 10, in class Note(db.Model): File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_sqlalchemy\model.py", line 100, in init super().init(name, bases, d, kwargs) File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\flask_sqlalchemy\model.py", line 120, in init super().init(name, bases, d, kwargs) File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\decl_api.py", line 199, in init _asdeclarative(reg, cls, dict) File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\decl_base.py", line 247, in _as_declarative return _MapperConfig.setupmapping(registry, cls, dict, None, {}) File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\decl_base.py", line 328, in setup_mapping return _ClassScanMapperConfig( File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\decl_base.py", line 578, in init self._early_mapping(mapper_kw) File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\decl_base.py", line 370, in _early_mapping self.map(mapper_kw) File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\decl_base.py", line 1791, in map mapper_cls(self.cls, self.local_table, **self.mapper_args), File "", line 2, in init File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\util\deprecations.py", line 277, in warned return fn(*args, **kwargs) # type: ignore[no-any-return] File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\mapper.py", line 859, in init__ self._configure_pks() File "C:\Users\Dan\AppData\Local\Programs\Python\Python310\lib\site-packages\sqlalchemy\orm\mapper.py", line 1601, in _configure_pks raise sa_exc.ArgumentError( sqlalchemy.exc.ArgumentError: Mapper Mapper[Note(note)] could not assemble any primary key columns for mapped table 'note'

DEMeyers commented 1 year ago

Closing issue.