【问题标题】:Install Apache-Airflow on iMac - airflow initdb - ImportError: cannot import name objects在 iMac 上安装 Apache-Airflow - 气流 initdb - ImportError:无法导入名称对象
【发布时间】:2019-01-03 19:00:21
【问题描述】:

我尝试在 iMac 上安装气流

airflow initdb

我收到了这个错误

Traceback (most recent call last):
    File "/Users/admin/anaconda/bin/airflow", line 21, in <module>
      from airflow import configuration
    File "/Users/admin/anaconda/lib/python2.7/site-packages/airflow/__init__.py", line 37, in <module>
      from airflow.models import DAG
    File "/Users/admin/anaconda/lib/python2.7/site-packages/airflow/models.py", line 32, in <module>
      import dill
    File "/Users/admin/anaconda/lib/python2.7/site-packages/dill/__init__.py", line 60, in <module>
      from . import objtypes as types
    File "/Users/admin/anaconda/lib/python2.7/site-packages/dill/objtypes.py", line 16, in <module>
      from dill import objects
    ImportError: cannot import name objects

我找到了这个帖子,While airflow initdb, ImportError: cannot import name HiveOperator,它不是用于在 iMac 上安装气流,并且错误不完全相同。但我还是试了一下。我改变了配置

# load_examples = True # default set up as True
load_examples = False # change to false to avoid airflow initdb error - But the error still there. 

但我在运行气流 initdb 时仍然遇到同样的错误。

【问题讨论】:

  • 会不会是因为你用的是anaconda,包dill和Python版本不一样?

标签: airflow


【解决方案1】:

您可能需要检查系统上安装的 dill 版本。 0.2a1 之前的版本(特别是 0.1a1 版本)不包含“对象”,并且会抛出您在上面看到的错误。

我在我的 mac 上创建了一个测试 conda 环境,并尝试通过 pip 安装使用各种版本的 dill 导入失败。

dill 版本 0.1a1 的结果:

(dill_test) pip install dill==0.1a1
Collecting dill==0.1a1
Installing collected packages: dill
Successfully installed dill-0.1a1
(dill_test)  python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
>>> from dill import objects
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name objects

dill 0.2a1 或更高版本的结果(导入对象时没有错误):

(dill_test) pip uninstall dill
Uninstalling dill-0.1a1:
  Would remove:
    /Users/.../anaconda2/envs/dill_test/lib/python2.7/site-packages/dill-    0.1a1.dist-info/*
    /Users/.../anaconda2/envs/dill_test/lib/python2.7/site-packages/dill/*
Proceed (y/n)? y
  Successfully uninstalled dill-0.1a1
(dill_test) pip install dill==0.2a1
Collecting dill==0.2a1
Installing collected packages: dill
Successfully installed dill-0.2a1
(dill_test) python
Python 2.7.15 |Anaconda, Inc.| (default, Dec 14 2018, 13:10:39)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
>>> from dill import objects
>>>

https://pypi.org/project/dill/

【讨论】:

  • 谢谢。这是莳萝问题的版本。在另一台 Mac 上,我有更新的 anaconda,我没有这个错误。气流 initdb 工作正常。我将尝试更新 anaconda 并查看是否可以解决问题
  • 但是当我在一个全新的环境(python 3)上尝试全新安装时,我在气流 initdb 时仍然出错。我会在另一个线程中问它。
猜你喜欢
  • 1970-01-01
  • 2013-03-13
  • 1970-01-01
  • 1970-01-01
  • 2018-05-11
  • 2019-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多