9

I am trying to install Airflow in EC2 (Amazon Linux) and "airflow initdb" fails with the following error:

$ AIRFLOW_HOME=/var/lib/airflow airflow initdb
[2019-09-07 20:51:32,416] {__init__.py:51} INFO - Using executor SequentialExecutor
Traceback (most recent call last):
  File "/bin/airflow", line 22, in <module>
    from airflow.bin.cli import CLIFactory
  File "/usr/lib/python2.7/site-packages/airflow/bin/cli.py", line 68, in <module>
    from airflow.www_rbac.app import cached_app as cached_app_rbac
  File "/usr/lib/python2.7/site-packages/airflow/www_rbac/app.py", line 26, in <module>
    from flask_appbuilder import AppBuilder, SQLA
  File "/usr/lib/python2.7/site-packages/flask_appbuilder/__init__.py", line 5, in <module>
    from .base import AppBuilder
  File "/usr/lib/python2.7/site-packages/flask_appbuilder/base.py", line 5, in <module>
    from .api.manager import OpenApiManager
  File "/usr/lib/python2.7/site-packages/flask_appbuilder/api/__init__.py", line 11, in <module>
    from marshmallow_sqlalchemy.fields import Related, RelatedList
  File "/usr/lib/python2.7/site-packages/marshmallow_sqlalchemy/__init__.py", line 1, in <module>
    from .schema import TableSchemaOpts, ModelSchemaOpts, TableSchema, ModelSchema
  File "/usr/lib/python2.7/site-packages/marshmallow_sqlalchemy/schema.py", line 101
    class TableSchema(ma.Schema, metaclass=TableSchemaMeta):
                                      ^
SyntaxError: invalid syntax

Since this is a syntax error, I suspect there is some version conflict between marshmallow_sqlalchemy and SQLAlchemy. Here are their versions:

apache-airflow==1.10.5
Flask==1.1.1
Flask-SQLAlchemy==2.4.0
marshmallow==2.20.3
marshmallow-enum==1.5.1
marshmallow-sqlalchemy==0.19.0
SQLAlchemy==1.3.8

Any idea?

Ilja Everilä
  • 50,538
  • 7
  • 126
  • 127
kee
  • 10,969
  • 24
  • 107
  • 168

1 Answers1

28

looks like the marshmallow-sqlalchemy version has upgraded, that is why you are getting this error. Uninstall the current version-

pip uninstall marshmallow-sqlalchemy

and try installing the below version, and then you should be good to go.

pip install marshmallow-sqlalchemy==0.17.1

I was also facing the similar issue but now it is resolved in the same way. Hope this helps!

Devasheesh Vaid
  • 296
  • 3
  • 3
  • 2
    Marshmallow-SQLAlchemy 0.18.0 was the last release to support Python 2.7: https://github.com/marshmallow-code/marshmallow-sqlalchemy/blob/dev/CHANGELOG.rst – Ilja Everilä Oct 05 '19 at 04:48