bash-4.1$ airflow initdb
Traceback (most recent call last):
  File "/u/bin/airflow", line 4, in <module>
    from airflow import configuration
  File "/u/lib/python2.7/site-packages/airflow/__init__.py", line 31, in <module>
    from airflow.models import DAG
  File "/u/lib/python2.7/site-packages/airflow/models.py", line 53, in <module>
    from croniter import croniter
  File "/u/lib/python2.7/site-packages/croniter/__init__.py", line 3, in <module>
    from .croniter import croniter
  File "/u/lib/python2.7/site-packages/croniter/croniter.py", line 8, in <module>
    from dateutil.relativedelta import relativedelta
  File "build/bdist.linux-x86_64/egg/dateutil/relativedelta.py", line 5, in <module>
ImportError: cannot import name integer_types

但解释器没有问题:
bash-4.1$ /u/bin/python2.7
Python 2.7.5 (default, Oct 17 2013, 14:04:34)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import croniter
>>>

我假设它必须做一些事情:
File "build/bdist.linux-x86_64/egg/dateutil/relativedelta.py", line 5, in <module>

所以在解释器中它使用来自 dateutil/u/lib/python2.7 而在 Airflow 中它使用来自 datutilbuild/bdist.linux-x86_64/egg/dateutil ??

我什至不知道 build/bdist.linux-x86_64/egg/dateutil 在哪里。

有人能告诉我发生了什么以及如何告诉 Airflow 从正确的 dateutil 导入吗?

最佳答案

您需要安装 Six python 包。

只需制作一个 pip install six

关于Python:从其他地方导入?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37709164/

10-12 23:06