最近,升级Python部分库版本后启动flask出现 如下错误很是诡异:
$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 15, in <module>
File "\Python\lib\site-packages\flask_migrate\__init__.py", line 12, in <module>
from alembic.config import Config as AlembicConfig
File "\Python\lib\site-packages\alembic\config.py", line 7, in <module>
from . import command
File "\Python\lib\site-packages\alembic\command.py", line 3, in <module>
from .script import ScriptDirectory
File "\Python\lib\site-packages\alembic\script\__init__.py", line 1, in <module>
from .base import ScriptDirectory, Script # noqa
File "\Python\lib\site-packages\alembic\script\base.py", line 2, in <module>
from dateutil import tz
File "\Python\lib\site-packages\dateutil\tz.py", line 78
`self._name`,
^
SyntaxError: invalid syntax
应该是dateutil 库文件版本不支持所致,解决办法:
pip install -U python-dateutil
Collecting python-dateutil
Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
|████████████████████████████████| 235kB 6.9kB/s
Installing collected packages: python-dateutil
Found existing installation: python-dateutil 1.5
Uninstalling python-dateutil-1.5:
Successfully uninstalled python-dateutil-1.5
Successfully installed python-dateutil-2.8.1
再次启动,问题解决。