Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install apache-airflow then airflow initdb on a fresh virtual environment: SyntaxError

Tags:

pip

airflow

$ virtualenv --version
16.3.0
$ pip --version
pip 19.0.1

I created a fresh environment. And run the

pip install apache-airflow

It is successful installed

apache-airflow   1.10.2 

But then I run the

 airflow initdb

I got the error

ERROR [airflow.models.DagBag] Failed to import: /Users/admin/workshops/apache/airflow/lib/python3.7/site-packages/airflow/example_dags/example_http_operator.py
    Traceback (most recent call last):
      File "/Users/admin/workshops/apache/airflow/lib/python3.7/site-packages/airflow/models.py", line 374, in process_file
        m = imp.load_source(mod_name, filepath)
      File "/Users/admin/workshops/apache/airflow/lib/python3.7/imp.py", line 171, in load_source
        module = _load(spec)
      File "<frozen importlib._bootstrap>", line 696, in _load
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/Users/admin/workshops/apache/airflow/lib/python3.7/site-packages/airflow/example_dags/example_http_operator.py", line 27, in <module>
        from airflow.operators.http_operator import SimpleHttpOperator
      File "/Users/admin/workshops/apache/airflow/lib/python3.7/site-packages/airflow/operators/http_operator.py", line 21, in <module>
        from airflow.hooks.http_hook import HttpHook
      File "/Users/admin/workshops/apache/airflow/lib/python3.7/site-packages/airflow/hooks/http_hook.py", line 23, in <module>
        import tenacity
      File "/Users/admin/workshops/apache/airflow/lib/python3.7/site-packages/tenacity/__init__.py", line 352
        from tenacity.async import AsyncRetrying
                          ^
    SyntaxError: invalid syntax

It is a fresh virtual environment. I did not install anything else.

like image 614
searain Avatar asked Mar 04 '23 15:03

searain


1 Answers

As can be found here, async has become a keyword since Python 3.7. You could create a virtual environment with Python < 3.7 and install Airflow. And perhaps you could also try and upgrade tenacity to >=4.10.0 as the issue in tenacity is resolved in that version.

like image 145
bartcode Avatar answered Apr 07 '23 16:04

bartcode