在運(yùn)行命令:
python wsgi.py
報(bào)錯(cuò):
Traceback (most recent call last):
File "wsgi.py", line 5, in <module>
app = create_app()
File "C:\Users\kegek\Desktop\flask_tencent\flaskr\__init__.py", line 52, in create_app
dbchemy.create_all()
File "C:\Users\kegek\Miniconda3\envs\flask\lib\site-packages\flask_sqlalchemy\__init__.py", line 1039, in create_all
self._execute_for_all_tables(app, bind, 'create_all')
File "C:\Users\kegek\Miniconda3\envs\flask\lib\site-packages\flask_sqlalchemy\__init__.py", line 1031, in _execute_for_all_ta
bles
op(bind=self.get_engine(app, bind), **extra)
File "C:\Users\kegek\Miniconda3\envs\flask\lib\site-packages\flask_sqlalchemy\__init__.py", line 962, in get_engine
return connector.get_engine()
File "C:\Users\kegek\Miniconda3\envs\flask\lib\site-packages\flask_sqlalchemy\__init__.py", line 555, in get_engine
options = self.get_options(sa_url, echo)
File "C:\Users\kegek\Miniconda3\envs\flask\lib\site-packages\flask_sqlalchemy\__init__.py", line 570, in get_options
self._sa.apply_driver_hacks(self._app, sa_url, options)
File "C:\Users\kegek\Miniconda3\envs\flask\lib\site-packages\flask_sqlalchemy\__init__.py", line 914, in apply_driver_hacks
sa_url.database = os.path.join(app.root_path, sa_url.database)
AttributeError: can't set attribute
run 在wsgi.py文件中app = create_app()時(shí),找init.py中create_app():執(zhí)行到dbchemy.create_all()或者是db.create_all()時(shí)铃肯,AttributeError: can't set attribute
參考文章的評(píng)論:https://discuss.helloflask.com/t/topic/662
知道了解決辦法
pip install -U flask-sqlalchemy
我當(dāng)前的 flask-sqlalchemy=2.4.4,看了文章說是庫(kù)的問題朴皆,已修復(fù)這個(gè)問題,目前包含這個(gè)修復(fù)的2.5.0版本已發(fā)布泛粹,更新后運(yùn)行成功。