You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "Navid61 (via GitHub)" <gi...@apache.org> on 2025/02/28 07:06:33 UTC
[I] DAG Import Errors [airflow]
Navid61 opened a new issue, #47197:
URL: https://github.com/apache/airflow/issues/47197
### Apache Airflow version
2.10.5
### If "Other Airflow 2 version" selected, which one?
_No response_
### What happened?
I am running Airflow using Docker, following the instructions for installing Apache Airflow on Debian 12.8 x64. However, when I create a file in the "dags" folder of my project, I encounter an error in the Airflow webserver container.

```bash
from airflow.providers.postgres.operators.postgres import PostgresOperator
ModuleNotFoundError: No module named 'airflow.providers.postgres.operators'
```
### What you think should happen instead?
I should be able to view my file (user_processing.py) in the list DAGs
### How to reproduce
When I attempted to execute this:
```python
from datetime import datetime
from airflow import DAG
from airflow.providers.postgres.operators.postgres import PostgresOperator
with DAG('user_processing', start_date=datetime(2024, 2,28), schedule_interval='@daily', catchup=False) as dag:
create_table =PostgresOperator(
task_id='create_table',
postgres_conn_id='postgres',
sql='''
CREATE TABLE IF NOT EXISTS users(
firstname TEXT NOT NULL,
lastname TEXT NOT NULL,
country TEXT NOT NULL,
username TEXT NOT NULL,
password TEXT NOT NULL,
email TEXT NOT NULL
);
'''
)
```
### Operating System
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"
### Versions of Apache Airflow Providers
_No response_
### Deployment
Docker-Compose
### Deployment details
_No response_
### Anything else?
This is a part of the log:
```bash
" 200 -
airflow-webserver-1 | 127.0.0.1 - - [28/Feb/2025:06:59:30 +0000] "GET /health HTTP/1.1" 200 318 "-" "curl/7.88.1"
airflow-scheduler-1 | [2025-02-28T06:59:33.703+0000] {processor.py:401} WARNING - Error when trying to pre-import module 'airflow.providers.postgres.operators.postgres' found in /opt/airflow/dags/user_processing.py: No module named 'airflow.providers.postgres.operators'
airflow-scheduler-1 | 127.0.0.1 - - [28/Feb/2025 06:59:55] "GET /health HTTP/1.1" 200 -
airflow-webserver-1 | 127.0.0.1 - - [28/Feb/2025:07:00:00 +0000] "GET /health HTTP/1.1" 200 318 "-" "curl/7.88.1"
airflow-scheduler-1 | [2025-02-28T07:00:04.546+0000] {processor.py:401} WARNING - Error when trying to pre-import module 'airflow.providers.postgres.operators.postgres' found in /opt/airflow/dags/user_processing.py: No module named 'airflow.providers.postgres.operators'
airflow-triggerer-1 | [2025-02-28T07:00:13.312+0000] {triggerer_job_runner.py:510} INFO - 0 triggers currently running
airflow-scheduler-1 | 127.0.0.1 - - [28/Feb/2025 07:00:25] "GET /health HTTP/1.1" 200 -
airflow-webserver-1 | 127.0.0.1 - - [28/Feb/2025:07:00:30 +0000] "GET /health HTTP/1.1" 200 318 "-" "curl/7.88.1"
airflow-scheduler-1 | [2025-02-28T07:00:35.427+0000] {processor.py:401} WARNING - Error when trying to pre-import module 'airflow.providers.postgres.operators.postgres' found in /opt/airflow/dags/user_processing.py: No module named 'airflow.providers.postgres.operators'
airflow-scheduler-1 | 127.0.0.1 - - [28/Feb/2025 07:00:55] "GET /health HTTP/1.1" 200 -
airflow-webserver-1 | 127.0.0.1 - - [28/Feb/2025:07:01:00 +0000] "GET /health HTTP/1.1" 200 318 "-" "curl/7.88.1"
airflow-scheduler-1 | [2025-02-28T07:01:05.707+0000] {processor.py:401} WARNING - Error when trying to pre-import module 'airflow.providers.postgres.operators.postgres' found in /opt/airflow/dags/user_processing.py: No module named 'airflow.providers.postgres.operators'
airflow-triggerer-1 | [2025-02-28T07:01:13.363+0000] {triggerer_job_runner.py:510} INFO - 0 triggers currently running
airflow-scheduler-1 | 127.0.0.1 - - [28/Feb/2025 07:01:25] "GET /health HTTP/1.1" 200 -
airflow-webserver-1 | 127.0.0.1 - - [28/Feb/2025:07:01:31 +0000] "GET /health HTTP/1.1" 200 318 "-" "curl/7.88.1"
airflow-scheduler-1 | [2025-02-28T07:01:36.063+0000] {processor.py:401} WARNING - Error when trying to pre-import module 'airflow.providers.postgres.operators.postgres' found in /opt/airflow/dags/user_processing.py: No module named 'airflow.providers.postgres.operators'
airflow-scheduler-1 | 127.0.0.1 - - [28/Feb/2025 07:01:55] "GET /health HTTP/1.1" 200 -
airflow-webserver-1 | 127.0.0.1 - - [28/Feb/2025:07:02:01 +0000] "GET /health HTTP/1.1" 200 318 "-" "curl/7.88.1"
airflow-scheduler-1 | [2025-02-28T07:02:06.490+0000] {processor.py:401} WARNING - Error when trying to pre-import module 'airflow.providers.postgres.operators.postgres' found in /opt/airflow/dags/user_processing.py: No module named 'airflow.providers.postgres.operators'
```
### Are you willing to submit PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] DAG Import Errors - No module named 'airflow.providers.postgres.operators' [airflow]
Posted by "Navid61 (via GitHub)" <gi...@apache.org>.
Navid61 closed issue #47197: DAG Import Errors - No module named 'airflow.providers.postgres.operators'
URL: https://github.com/apache/airflow/issues/47197
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] DAG Import Errors - No module named 'airflow.providers.postgres.operators' [airflow]
Posted by "Navid61 (via GitHub)" <gi...@apache.org>.
Navid61 commented on issue #47197:
URL: https://github.com/apache/airflow/issues/47197#issuecomment-2690045420
Yes, you were right. I found instructions on how to use the SQLExecuteQueryOperator here: https://github.com/apache/airflow/blob/providers-postgres/6.1.0/providers/postgres/tests/system/postgres/example_postgres.py
```python
import datetime
from airflow import DAG
from airflow.providers.common.sql.operators.sql import SQLExecuteQueryOperator
DAG_ID='user_processing'
with DAG(dag_id=DAG_ID, start_date=datetime.datetime(2024, 2, 28),schedule="@daily",catchup=False) as dag:
create_table = SQLExecuteQueryOperator(
task_id='create_table',
conn_id='postgres',
database='postgres',
sql='''
CREATE TABLE IF NOT EXISTS users(
firstname TEXT NOT NULL,
lastname TEXT NOT NULL,
country TEXT NOT NULL,
username TEXT NOT NULL,
password TEXT NOT NULL,
email TEXT NOT NULL
);
'''
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] DAG Import Errors - No module named 'airflow.providers.postgres.operators' [airflow]
Posted by "vatsrahul1001 (via GitHub)" <gi...@apache.org>.
vatsrahul1001 commented on issue #47197:
URL: https://github.com/apache/airflow/issues/47197#issuecomment-2689974722
@Navid61 `airflow.providers.postgres.operators.postgres.PostgresOperator` isdeprecated please use `airflow.providers.common.sql.operators.sql.SQLExecuteQueryOperator` instead.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] DAG Import Errors [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #47197:
URL: https://github.com/apache/airflow/issues/47197#issuecomment-2689896142
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org