棉花糖sqlalchemy给出语法错误



在python 3.5中安装marshmallow-sqlalchemy后,显示语法错误。

我使用以下命令pip install marshmallow-sqlalchemy安装了它。

Traceback (most recent call last):
File "run.py", line 1, in <module>
from app import flask_app
File "/var/www/html/mswipe-banner/mswipe-banner/app/__init__.py", line 10, in <module>
from .models import *
File "/var/www/html/mswipe-banner/mswipe-banner/app/models/__init__.py", line 1, in <module>
from .banner import *
File "/var/www/html/mswipe-banner/mswipe-banner/app/models/banner.py", line 1, in <module>
from .base_model import *
File "/var/www/html/mswipe-banner/mswipe-banner/app/models/base_model.py", line 1, in <module>
from flask_marshmallow import Marshmallow
File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/flask_marshmallow/__init__.py", line 24, in <module>
from . import sqla
File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/flask_marshmallow/sqla.py", line 13, in <module>
import marshmallow_sqlalchemy as msqla
File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/marshmallow_sqlalchemy/__init__.py", line 1, in <module>
from .schema import TableSchemaOpts, ModelSchemaOpts, TableSchema, ModelSchema
File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/marshmallow_sqlalchemy/schema.py", line 3, in <module>
from .convert import ModelConverter
File "/var/www/html/mswipe-banner/lib/python3.5/site-packages/marshmallow_sqlalchemy/convert.py", line 80
):
^
SyntaxError: invalid syntax

谢谢😊

由于棉花糖sqlalchemy不再支持Python 3.5,安装失败。最后一个支持Python 3.5的版本是18.0版本,必须显式安装。

回溯中的特定错误是由以下函数声明引起的:

def fields_for_model(
self,
model,
*,
include_fk=False,
fields=None,
exclude=None,
base_fields=None,
dict_cls=dict,
):

Python 3.6中包含了一项更改,允许在函数参数列表中使用尾随逗号。在此更改之前,这些签名是合法的:

>>> def f(a, b, c=1,):pass
... 
>>> def f(a, b, *, c=1):pass
... 
>>>

但这不是

>>> def f(a, b, *, c=1,):pass
File "<stdin>", line 1
def f(a, b, *, c=1,):pass
^
SyntaxError: invalid syntax

参数列表中间的*(表示只使用关键字的参数的开始(在版本18之后添加到上面的棉花糖-sqlalchemy函数签名中,作为删除2.7和3.5兼容性过程的一部分。

相关内容

  • 没有找到相关文章

最新更新