virtualenv 上的 apache 气流:错误 - 加密值时无法加载 fernet

Sim*_*tis 3 python virtualenv python-2.7 airflow

我正在尝试在 virtualenv 上安装 Apache Airflow。

首先我创建并激活了一个新的 python 虚拟环境,然后我通过 pip 安装了 apache-airflow。

$ virtualenv $HOME/.p2env -p /usr/bin/python
Running virtualenv with interpreter /usr/bin/python
New python executable in /home/cass/.p2env/bin/python
Installing setuptools, pip, wheel...done.
$ source $HOME/.p2env/bin/activate
(.p2env) $ pip install apache-airflow
Run Code Online (Sandbox Code Playgroud)

然后我尝试初始化气流元数据数据库我收到这些错误:

(.p2env) $ airflow initdb            
[2018-03-14 16:50:22,924] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/Grammar.txt
[2018-03-14 16:50:22,944] {driver.py:120} INFO - Generating grammar tables from /usr/lib/python2.7/lib2to3/PatternGrammar.txt
[2018-03-14 16:50:23,043] {__init__.py:45} INFO - Using executor SequentialExecutor
DB: sqlite:////home/cass/airflow/airflow.db
[2018-03-14 16:50:23,128] {db.py:312} INFO - Creating tables
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
INFO  [alembic.runtime.migration] Running upgrade  -> e3a246e0dc1, current schema
INFO  [alembic.runtime.migration] Running upgrade e3a246e0dc1 -> 1507a7289a2f, create is_encrypted
/home/cass/.p2env/local/lib/python2.7/site-packages/alembic/util/messaging.py:69: UserWarning: Skipping unsupported ALTER for creation of implicit constraint
  warnings.warn(msg)
INFO  [alembic.runtime.migration] Running upgrade 1507a7289a2f -> 13eb55f81627, maintain history for compatibility with earlier migrations
INFO  [alembic.runtime.migration] Running upgrade 13eb55f81627 -> 338e90f54d61, More logging into task_isntance
INFO  [alembic.runtime.migration] Running upgrade 338e90f54d61 -> 52d714495f0, job_id indices
INFO  [alembic.runtime.migration] Running upgrade 52d714495f0 -> 502898887f84, Adding extra to Log
INFO  [alembic.runtime.migration] Running upgrade 502898887f84 -> 1b38cef5b76e, add dagrun
INFO  [alembic.runtime.migration] Running upgrade 1b38cef5b76e -> 2e541a1dcfed, task_duration
INFO  [alembic.runtime.migration] Running upgrade 2e541a1dcfed -> 40e67319e3a9, dagrun_config
INFO  [alembic.runtime.migration] Running upgrade 40e67319e3a9 -> 561833c1c74b, add password column to user
INFO  [alembic.runtime.migration] Running upgrade 561833c1c74b -> 4446e08588, dagrun start end
INFO  [alembic.runtime.migration] Running upgrade 4446e08588 -> bbc73705a13e, Add notification_sent column to sla_miss
INFO  [alembic.runtime.migration] Running upgrade bbc73705a13e -> bba5a7cfc896, Add a column to track the encryption state of the 'Extra' field in connection
INFO  [alembic.runtime.migration] Running upgrade bba5a7cfc896 -> 1968acfc09e3, add is_encrypted column to variable table
INFO  [alembic.runtime.migration] Running upgrade 1968acfc09e3 -> 2e82aab8ef20, rename user table
INFO  [alembic.runtime.migration] Running upgrade 2e82aab8ef20 -> 211e584da130, add TI state index
INFO  [alembic.runtime.migration] Running upgrade 211e584da130 -> 64de9cddf6c9, add task fails journal table
INFO  [alembic.runtime.migration] Running upgrade 64de9cddf6c9 -> f2ca10b85618, add dag_stats table
INFO  [alembic.runtime.migration] Running upgrade f2ca10b85618 -> 4addfa1236f1, Add fractional seconds to mysql tables
INFO  [alembic.runtime.migration] Running upgrade 4addfa1236f1 -> 8504051e801b, xcom dag task indices
INFO  [alembic.runtime.migration] Running upgrade 8504051e801b -> 5e7d17757c7a, add pid field to TaskInstance
INFO  [alembic.runtime.migration] Running upgrade 5e7d17757c7a -> 127d2bf2dfa7, Add dag_id/state index on dag_run table
INFO  [alembic.runtime.migration] Running upgrade 127d2bf2dfa7 -> cc1e65623dc7, add max tries column to task instance
[2018-03-14 16:50:23,639] {models.py:189} INFO - Filling up the DagBag from /home/cass/airflow/dags
INFO  [alembic.runtime.migration] Running upgrade cc1e65623dc7 -> bdaa763e6c56, Make xcom value column a large binary
INFO  [alembic.runtime.migration] Running upgrade bdaa763e6c56 -> 947454bf1dff, add ti job_id index
INFO  [alembic.runtime.migration] Running upgrade 947454bf1dff -> d2ae31099d61, Increase text size for MySQL (not relevant for other DBs' text types)
[2018-03-14 16:50:23,795] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,803] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,818] {models.py:614} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 610, in set_password
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,864] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,917] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,941] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,949] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,956] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,977] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:23,994] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:24,009] {models.py:643} ERROR - Failed to load fernet while encrypting value, using non-encrypted value.
Traceback (most recent call last):
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 639, in set_extra
    fernet = get_fernet()
  File "/home/cass/.p2env/local/lib/python2.7/site-packages/airflow/models.py", line 103, in get_fernet
    raise AirflowException('Failed to import Fernet, it may not be installed')
AirflowException: Failed to import Fernet, it may not be installed
[2018-03-14 16:50:24,041] {models.py:189} INFO - Filling up the DagBag from /home/cass/airflow/dags
[2018-03-14 16:50:24,117] {models.py:3809} INFO - Creating ORM DAG for example_skip_dag
[2018-03-14 16:50:24,127] {models.py:3809} INFO - Creating ORM DAG for test_utils
[2018-03-14 16:50:24,136] {models.py:3809} INFO - Creating ORM DAG for example_subdag_operator.section-2
[2018-03-14 16:50:24,145] {models.py:3809} INFO - Creating ORM DAG for example_subdag_operator.section-1
[2018-03-14 16:50:24,153] {models.py:3809} INFO - Creating ORM DAG for example_passing_params_via_test_command
[2018-03-14 16:50:24,162] {models.py:3809} INFO - Creating ORM DAG for example_branch_dop_operator_v3
[2018-03-14 16:50:24,172] {models.py:3809} INFO - Creating ORM DAG for example_python_operator
[2018-03-14 16:50:24,181] {models.py:3809} INFO - Creating ORM DAG for example_bash_operator
[2018-03-14 16:50:24,190] {models.py:3809} INFO - Creating ORM DAG for latest_only_with_trigger
[2018-03-14 16:50:24,199] {models.py:3809} INFO - Creating ORM DAG for example_trigger_target_dag
[2018-03-14 16:50:24,209] {models.py:3809} INFO - Creating ORM DAG for example_branch_operator
[2018-03-14 16:50:24,220] {models.py:3809} INFO - Creating ORM DAG for example_subdag_operator
[2018-03-14 16:50:24,244] {models.py:3809} INFO - Creating ORM DAG for latest_only
[2018-03-14 16:50:24,253] {models.py:3809} INFO - Creating ORM DAG for example_http_operator
[2018-03-14 16:50:24,263] {models.py:3809} INFO - Creating ORM DAG for example_xcom
[2018-03-14 16:50:24,271] {models.py:3809} INFO - Creating ORM DAG for tutorial
[2018-03-14 16:50:24,280] {models.py:3809} INFO - Creating ORM DAG for example_trigger_controller_dag
[2018-03-14 16:50:24,290] {models.py:3809} INFO - Creating ORM DAG for example_short_circuit_operator
Done.
Run Code Online (Sandbox Code Playgroud)

并且可能网络服务器无法启动。

(.p2env) $ airflow webserver -p 8080
[2018-03-14 16:50:35 +0000] [27606] [ERROR] Can't connect to ('0.0.0.0', 8080)
Run Code Online (Sandbox Code Playgroud)

操作系统:Ubuntu 16.04.3 LTS

蟒蛇:2.7.12

更新:

我必须安装cryptographypython 模块:pip install cryptography.

airflow initdb 运行成功

Sim*_*tis 5

我必须安装cryptographypython 模块:pip install cryptography.

之后,airflow initdb运行成功。