为什么在 Mac 上安装 Apache Airflow 时没有出现此类表错误? [英] Why do I get no such table error when installing Apache Airflow on Mac?

查看:37
本文介绍了为什么在 Mac 上安装 Apache Airflow 时没有出现此类表错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很难给出正确的标题.好的,就到这里了.我正在按照本教程在我的 Mac(Mojave 版本)上安装 Apache Airflow -

It was so hard to put that right title. Ok, here it goes. I was following this tutorial to install Apache Airflow on my Mac (Mojave version) -

https://towardsdatascience.com/getting-started-with-apache-气流-df1aa77d7b1b

就在执行 pip 安装气流任务后的第一步,当我运行气流版本命令时,我收到以下错误,然后出现气流版本 -

Right at the first step after performing the pip install airflow task, when I run the airflow version command I am getting the following error and then the airflow version appears -

错误 - 使用 Traceback 执行前回调失败(最近一次调用):文件"/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py",第 1244 行,在 _execute_context 中游标、语句、参数、上下文文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/default.py",第 552 行,在 do_execute 中cursor.execute(statement, parameters) sqlite3.OperationalError: no such table: log

ERROR - Failed on pre-execution callback using Traceback (most recent call last): File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute cursor.execute(statement, parameters) sqlite3.OperationalError: no such table: log

上述异常是以下异常的直接原因:

The above exception was the direct cause of the following exception:

回溯(最近一次调用最后一次):文件"/Users/karthikv/anaconda3/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py",第 68 行,在 on_pre_execution 中cb(**kwargs) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py",第 99 行,在 default_action_log 中session.add(log) 文件/Users/karthikv/anaconda3/lib/python3.7/contextlib.py",第 119 行,在退出下一个(self.gen)文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/airflow/utils/db.py",第 45 行,在 create_session 中session.commit() 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py",第 1026 行,提交中self.transaction.commit() 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py",第 493 行,提交中self._prepare_impl() 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py",第 472 行,在 _prepare_impl 中self.session.flush() 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py",第 2451 行,齐平self._flush(objects) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py",第 2589 行,在 _flush 中transaction.rollback(_capture_exception=True) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py",第 68 行,在 出口compat.reraise(exc_type, exc_value, exc_tb) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/compat.py",第 129 行,再次加注提高值文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py",第 2549 行,在 _flush 中flush_context.execute() 文件 "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py",第 422 行,执行中rec.execute(self) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py",第 589 行,执行中uow,文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py",第 245 行,在 save_obj 中插入,文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py",第 1120 行,在 _emit_insert_statements 中声明,参数文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py",第 988 行,执行中返回 meth(self, multiparams, params) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/sql/elements.py",第 287 行,在 _execute_on_connection 中返回 connection._execute_clauseelement(self, multiparams, params) 文件"/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py",第 1107 行,在 _execute_clauseelement 中distilled_pa​​rams,文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py",第 1248 行,在 _execute_context 中e、语句、参数、光标、上下文文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py",第 1466 行,在 _handle_dbapi_exception 中util.raise_from_cause(sqlalchemy_exception, exc_info) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/compat.py",第 383 行,在 raise_from_cause 中重新提出(类型(异常),异常,tb=exc_tb,原因=原因)文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/compat.py",第 128 行,再加注提高 value.with_traceback(tb) 文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py",第 1244 行,在 _execute_context 中游标、语句、参数、上下文文件/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/default.py",第 552 行,在 do_execute 中cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) 没有这样的表:日志 [SQL:插入日志(dttm,dag_id,task_id,事件,execution_date, owner, extra) VALUES (?, ?, ?, ?, ?, ?, ?)][参数:('2019-08-12 20:50:24.960006', None, None, 'cli_version',无, 'karthikv', '{"host_name": "192-168-1-6.tpgi.com.au","full_command": "[\'/Users/karthikv/anaconda3/bin/airflow\',\'版本\']"}')]

Traceback (most recent call last): File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py", line 68, in on_pre_execution cb(**kwargs) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/airflow/utils/cli_action_loggers.py", line 99, in default_action_log session.add(log) File "/Users/karthikv/anaconda3/lib/python3.7/contextlib.py", line 119, in exit next(self.gen) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/airflow/utils/db.py", line 45, in create_session session.commit() File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1026, in commit self.transaction.commit() File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 493, in commit self._prepare_impl() File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 472, in _prepare_impl self.session.flush() File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2451, in flush self._flush(objects) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2589, in _flush transaction.rollback(_capture_exception=True) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/langhelpers.py", line 68, in exit compat.reraise(exc_type, exc_value, exc_tb) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 129, in reraise raise value File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 2549, in _flush flush_context.execute() File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 422, in execute rec.execute(self) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/unitofwork.py", line 589, in execute uow, File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 245, in save_obj insert, File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/orm/persistence.py", line 1120, in _emit_insert_statements statement, params File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute return meth(self, multiparams, params) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection return connection._execute_clauseelement(self, multiparams, params) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement distilled_params, File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context e, statement, parameters, cursor, context File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1466, in _handle_dbapi_exception util.raise_from_cause(sqlalchemy_exception, exc_info) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 383, in raise_from_cause reraise(type(exception), exception, tb=exc_tb, cause=cause) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 128, in reraise raise value.with_traceback(tb) File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1244, in _execute_context cursor, statement, parameters, context File "/Users/karthikv/anaconda3/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 552, in do_execute cursor.execute(statement, parameters) sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such table: log [SQL: INSERT INTO log (dttm, dag_id, task_id, event, execution_date, owner, extra) VALUES (?, ?, ?, ?, ?, ?, ?)] [parameters: ('2019-08-12 20:50:24.960006', None, None, 'cli_version', None, 'karthikv', '{"host_name": "192-168-1-6.tpgi.com.au", "full_command": "[\'/Users/karthikv/anaconda3/bin/airflow\', \'version\']"}')]

(此错误的背景:http://sqlalche.me/e/e3q8)

有人可以帮助我这个错误意味着什么以及如何解决它?我从说明中了解到,默认情况下会安装 SQLLite db,并且在我们开始设置后端数据库(例如 PostgreSQL)之前,将设置单个 DAG 限制.

Can someone help me what this error means and how to solve it? I understand from the instructions that by default SQLLite db gets installed and a single DAG restrictions would be in place before we get into setting up backend database say PostgreSQL.

我尝试使用pip卸载气流卸载以再次执行全新安装.我收到以下错误 -

I tried to uninstall using pip uninstall airflow to perform clean installation again. I get the following error -

警告:跳过气流,因为它没有安装.

WARNING: Skipping airflow as it is not installed.

请帮助我解决问题(或)为我提供可以进一步阅读的资源.

Kindly help me in solving the issue (or) pointing me to resources where I can do further reading.

推荐答案

安装后需要进行初始化:

You need to perform initialization after installation:

$ export AIRFLOW_HOME=some/dir
$ airflow db init  # or `airflow initdb` for the legacy 1.X

如果 AIRFLOW_HOME 未设置,~/airflow/ 将被创建和使用.这是存储配置和日志的地方;如果要重置配置,请删除存储在 AIRFLOW_HOME 中的目录并重新运行 airflow db init.

If AIRFLOW_HOME is unset, ~/airflow/ will be created and used. This is where the config and logs will be stored; if you want to reset the configuration, remove the dir stored in AIRFLOW_HOME and rerun airflow db init.

现在其他命令应该可以工作了,例如

Now other commands should work, e.g.

$ airflow db check
[2021-02-06 23:35:21,577] {db.py:756} INFO - Connection successful.

来源:初始化气流数据库 airflow 文档中的部分.感谢 Anas Tiour,他在 这条评论!

Source: Initializing Airflow Database section from airflow docs. Kudos to Anas Tiour who notified about the command line interface change in 2.0.0 in this comment!

这篇关于为什么在 Mac 上安装 Apache Airflow 时没有出现此类表错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆