我试图建立与气流和Postgres的码头,但在建立过程中得到了许多错误,如下所示。我先试着在Requirements.txt中添加了一些在互联网上找到的解决方案,建议降低标记的版本,但这根本没有帮助。我能做些什么来解决这个问题?
markupsafe==2.1.1
and then also
markupsafe==2.0.1
错误:
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py)
Docker文件:
version: '3'
services:
postgres:
image: postgres:11.2
environment:
- POSTGRES_USER=airflow
- POSTGRES_PASSWORD=airflow
- POSTGRES_DB=airflow
ports:
- "5432:5432"
webserver:
image: puckel/docker-airflow:1.10.4
build:
context: https://github.com/puckel/docker-airflow.git#1.10.4
dockerfile: Dockerfile
args:
AIRFLOW_DEPS: gcp_api,s3
restart: always
depends_on:
- postgres
environment:
- LOAD_EX=n
- EXECUTOR=Local
- FERNET_KEY=jsDPRErfv8Z_eVTnGfF8ywd19j4pyqE3NpdUBA_oRTo=
volumes:
- ./sparkify/dags:/usr/local/airflow/dags
# Uncomment to include custom plugins
- ./sparkify/plugins:/usr/local/airflow/plugins
ports:
- "8081:8081"
command: webserver
healthcheck:
test: ["CMD-SHELL", "[ -f /usr/local/airflow/airflow-webserver.pid ]"]
interval: 30s
timeout: 30s
retries: 3
requirements:
image: python:3.8-alpine
volumes:
- .:/sparkify
working_dir: /sparkify
command: pip3 install -r requirements.txt
Requirments.txt:
markupsafe==2.0.1
完全错误:
Creating network "airflowwithpostgres_default" with the default driver
Creating airflowwithpostgres_postgres_1 ... done
Creating airflowwithpostgres_requirements_1 ... done
Creating airflowwithpostgres_webserver_1 ... done
Attaching to airflowwithpostgres_requirements_1, airflowwithpostgres_postgres_1, airflowwithpostgres_webserver_1
postgres_1 | The files belonging to this database system will be owned by user "postgres".
postgres_1 | This user must also own the server process.
postgres_1 |
webserver_1 | Tue May 10 18:38:28 UTC 2022 - waiting for Postgres... 1/20
postgres_1 | The database cluster will be initialized with locale "en_US.utf8".
postgres_1 | The default database encoding has accordingly been set to "UTF8".
postgres_1 | The default text search configuration will be set to "english".
postgres_1 |
postgres_1 | Data page checksums are disabled.
postgres_1 |
postgres_1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok
postgres_1 | creating subdirectories ... ok
postgres_1 | selecting default max_connections ... 100
postgres_1 | selecting default shared_buffers ... 128MB
postgres_1 | selecting dynamic shared memory implementation ... posix
postgres_1 | creating configuration files ... ok
postgres_1 | running bootstrap script ... ok
postgres_1 | performing post-bootstrap initialization ... ok
postgres_1 | syncing data to disk ...
postgres_1 | WARNING: enabling "trust" authentication for local connections
postgres_1 | You can change this by editing pg_hba.conf or using the option -A, or
postgres_1 | --auth-local and --auth-host, the next time you run initdb.
postgres_1 | ok
postgres_1 |
postgres_1 | Success. You can now start the database server using:
postgres_1 |
postgres_1 | pg_ctl -D /var/lib/postgresql/data -l logfile start
postgres_1 |
postgres_1 | waiting for server to start....2022-05-10 18:38:29.428 UTC [44] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2022-05-10 18:38:29.441 UTC [45] LOG: database system was shut down at 2022-05-10 18:38:29 UTC
postgres_1 | 2022-05-10 18:38:29.446 UTC [44] LOG: database system is ready to accept connections
postgres_1 | done
postgres_1 | server started
postgres_1 | CREATE DATABASE
postgres_1 |
postgres_1 |
postgres_1 | /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
postgres_1 |
postgres_1 | 2022-05-10 18:38:29.859 UTC [44] LOG: received fast shutdown request
postgres_1 | waiting for server to shut down....2022-05-10 18:38:29.861 UTC [44] LOG: aborting any active transactions
postgres_1 | 2022-05-10 18:38:29.865 UTC [44] LOG: background worker "logical replication launcher" (PID 51) exited with exit code 1
postgres_1 | 2022-05-10 18:38:29.865 UTC [46] LOG: shutting down
postgres_1 | 2022-05-10 18:38:29.882 UTC [44] LOG: database system is shut down
postgres_1 | done
postgres_1 | server stopped
postgres_1 |
postgres_1 | PostgreSQL init process complete; ready for start up.
postgres_1 |
postgres_1 | 2022-05-10 18:38:29.974 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2022-05-10 18:38:29.974 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2022-05-10 18:38:29.976 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2022-05-10 18:38:29.989 UTC [62] LOG: database system was shut down at 2022-05-10 18:38:29 UTC
postgres_1 | 2022-05-10 18:38:29.994 UTC [1] LOG: database system is ready to accept connections
requirements_1 | Collecting markupsafe==2.1.1
requirements_1 | Downloading MarkupSafe-2.1.1-cp38-cp38-musllinux_1_1_x86_64.whl (29 kB)
requirements_1 | Installing collected packages: markupsafe
requirements_1 | Successfully installed markupsafe-2.1.1
requirements_1 | WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
airflowwithpostgres_requirements_1 exited with code 0
postgres_1 | 2022-05-10 18:38:33.377 UTC [69] LOG: incomplete startup packet
webserver_1 | Traceback (most recent call last):
webserver_1 | File "/usr/local/bin/airflow", line 21, in <module>
webserver_1 | from airflow import configuration
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 39, in <module>
webserver_1 | from airflow.models import DAG
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/__init__.py", line 21, in <module>
webserver_1 | from airflow.models.baseoperator import BaseOperator # noqa: F401
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 30, in <module>
webserver_1 | import jinja2
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/__init__.py", line 33, in <module>
webserver_1 | from jinja2.environment import Environment, Template
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in <module>
webserver_1 | from jinja2 import nodes
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in <module>
webserver_1 | from jinja2.utils import Markup
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in <module>
webserver_1 | from markupsafe import Markup, escape, soft_unicode
webserver_1 | ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py)
webserver_1 | Traceback (most recent call last):
webserver_1 | File "/usr/local/bin/airflow", line 21, in <module>
webserver_1 | from airflow import configuration
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 39, in <module>
webserver_1 | from airflow.models import DAG
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/__init__.py", line 21, in <module>
webserver_1 | from airflow.models.baseoperator import BaseOperator # noqa: F401
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 30, in <module>
webserver_1 | import jinja2
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/__init__.py", line 33, in <module>
webserver_1 | from jinja2.environment import Environment, Template
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in <module>
webserver_1 | from jinja2 import nodes
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in <module>
webserver_1 | from jinja2.utils import Markup
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in <module>
webserver_1 | from markupsafe import Markup, escape, soft_unicode
webserver_1 | ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py)
webserver_1 | Traceback (most recent call last):
webserver_1 | File "/usr/local/bin/airflow", line 21, in <module>
webserver_1 | from airflow import configuration
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 39, in <module>
webserver_1 | from airflow.models import DAG
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/__init__.py", line 21, in <module>
webserver_1 | from airflow.models.baseoperator import BaseOperator # noqa: F401
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 30, in <module>
webserver_1 | import jinja2
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/__init__.py", line 33, in <module>
webserver_1 | from jinja2.environment import Environment, Template
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in <module>
webserver_1 | from jinja2 import nodes
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in <module>
webserver_1 | from jinja2.utils import Markup
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in <module>
webserver_1 | from markupsafe import Markup, escape, soft_unicode
webserver_1 | ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py)
postgres_1 | 2022-05-10 18:38:35.020 UTC [70] LOG: incomplete startup packet
webserver_1 | Traceback (most recent call last):
webserver_1 | File "/usr/local/bin/airflow", line 21, in <module>
webserver_1 | from airflow import configuration
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 39, in <module>
webserver_1 | from airflow.models import DAG
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/__init__.py", line 21, in <module>
webserver_1 | from airflow.models.baseoperator import BaseOperator # noqa: F401
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 30, in <module>
webserver_1 | import jinja2
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/__init__.py", line 33, in <module>
webserver_1 | from jinja2.environment import Environment, Template
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in <module>
webserver_1 | from jinja2 import nodes
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in <module>
webserver_1 | from jinja2.utils import Markup
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in <module>
webserver_1 | from markupsafe import Markup, escape, soft_unicode
webserver_1 | ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py)
webserver_1 | Traceback (most recent call last):
webserver_1 | File "/usr/local/bin/airflow", line 21, in <module>
webserver_1 | from airflow import configuration
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 39, in <module>
webserver_1 | from airflow.models import DAG
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/__init__.py", line 21, in <module>
webserver_1 | from airflow.models.baseoperator import BaseOperator # noqa: F401
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 30, in <module>
webserver_1 | import jinja2
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/__init__.py", line 33, in <module>
webserver_1 | from jinja2.environment import Environment, Template
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in <module>
webserver_1 | from jinja2 import nodes
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in <module>
webserver_1 | from jinja2.utils import Markup
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in <module>
webserver_1 | from markupsafe import Markup, escape, soft_unicode
webserver_1 | ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py)
webserver_1 | Traceback (most recent call last):
webserver_1 | File "/usr/local/bin/airflow", line 21, in <module>
webserver_1 | from airflow import configuration
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/__init__.py", line 39, in <module>
webserver_1 | from airflow.models import DAG
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/__init__.py", line 21, in <module>
webserver_1 | from airflow.models.baseoperator import BaseOperator # noqa: F401
webserver_1 | File "/usr/local/lib/python3.7/site-packages/airflow/models/baseoperator.py", line 30, in <module>
webserver_1 | import jinja2
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/__init__.py", line 33, in <module>
webserver_1 | from jinja2.environment import Environment, Template
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/environment.py", line 15, in <module>
webserver_1 | from jinja2 import nodes
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/nodes.py", line 19, in <module>
webserver_1 | from jinja2.utils import Markup
webserver_1 | File "/usr/local/lib/python3.7/site-packages/jinja2/utils.py", line 642, in <module>
webserver_1 | from markupsafe import Markup, escape, soft_unicode
webserver_1 | ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.7/site-packages/markupsafe/__init__.py)
airflowwithpostgres_webserver_1 exited with code 1
7条答案
按热度按时间vaj7vani1#
降级MARKUP SAFE至2.0.1
pip install markupsafe==2.0.1
3qpi33ja2#
原来
markupsafe
删除了导致此错误的‘soft_unicode’!https://github.com/pallets/markupsafe/issues/304将
MarkupSafe==2.0.1
添加到PYTHON_DEPS
,如下所示:然后运行
docker-compose down
,然后运行docker-compose up -d --build
,所有服务都应该正在运行!如果你收到另一封邮件,你可以像这样把包裹添加到
PYTHON_DEPS
中:jckbn6z73#
我在Linux上使用的是Python3.7.6,在我的情况下,我只需升级FASK版本,一切都会再次正常工作:
whlutmcx4#
这并不能单独解决我的问题。
以下就是原因所在:
1.我卸载并重新安装了ZMQ。
1.我安装了markupSafe 2.0.1版本。
1.打开jupyter笔记本
xuo3flqw5#
在Mac OS X Marports with Python3.8中,我通过以下方式解决了这个问题:
eit6fx6z6#
对于任何降级但仍面临问题的人。
进入已经存在的目录,删除它,重新安装降级版本。
PIP安装markupsafe==2.0.1本身不会修复问题,除非删除已存在的标记文件。
b4lqfgs47#
从您的日志中可以看出,根本原因是
jinja2
(旧?)与其依赖项markupsafe
(较新?)不兼容。有些东西使jinja2
固定在较旧的、不兼容的版本上。你可以将“太新”的套餐降级(大多数答案通常建议在这种情况下作为一种解决办法,从而造成科技债务,从而让你背上一口气),或者(更好的)将“太旧”的套餐升级到最新版本:jinja2
。例如,通过简单地将
jinja
固定到不兼容的版本(例如,jinja2==2.11.3
-一个非常流行的“最新工作”版本Pin:),同时保持其他连接的(即,反向依赖的,也是递归的)包的最新版本(例如,Flask==2.2.2
、itsdangerous==2.1.2
、Werkzeug==2.2.2
等),就可以复制该错误。取消固定jinja2
并让其升级(到3.1.2
)可以解决ImportError
。另请注意,如果打印
MarkupSafe
的反向依赖关系,则如下所示:您将看到
Jinja2
需要此程序包的哪些最低版本: