英文:
Airflow can't find main module after install
问题
I just installed Python 3.10.11 on Suse SLES-15.4. Python runs as expected:
~> python3 -c "import os, sys; print(os.path.dirname(sys.executable))"
/usr/bin
~> pip3 --version
pip 22.0.4 from /usr/lib/python3.10/site-packages/pip (python 3.10)
As I am not a fan of having an aplication installed in my personal home folder, so I defined the AIRFLOW_HOME to a directory which I created:
export AIRFLOW_HOME=/usr/lib/airflow
Then, as written in the quick start guide, I defined the following variables:
AIRFLOW_VERSION=2.6.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CONSTRAINT_URL=https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt
and then proceeded with install:
pip3 install -t $AIRFLOW_HOME "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
I tried to configure the /etc/profile.d/python.sh to guess what could prevent Airflow from starting:
# add python startup script for interactive sessions
export PYTHONSTARTUP=/etc/pythonstart
export LC_ALL="fr_CH.UTF-8"
export AIRFLOW_HOME=/usr/lib/airflow
export PATH=/usr/lib:/usr/lib/airflow:/usr/lib/airflow/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib/airflow:/usr/lib/airflow/bin/airflow:/usr/lib/python3.10:/usr/lib/python3.10/site-packages:$LD_LIBRARY_PATH
But still, when I try to run Airflow at first, I receive an error message:
~> airflow standalone
Traceback (most recent call last):
File "/usr/lib/airflow/bin/airflow", line 5, in <module>
from airflow.__main__ import main
ModuleNotFoundError: No module named 'airflow'
Do you have any suggestion to solve this?
英文:
I just installed Python 3.10.11 on Suse SLES-15.4.
Python runs as expected:
~> python3 -c "import os, sys; print(os.path.dirname(sys.executable))"
/usr/bin
~> pip3 --version
pip 22.0.4 from /usr/lib/python3.10/site-packages/pip (python 3.10)
As I am not a fan of having an aplication installed in my personal home folder, so I defined the AIRFLOW_HOME to a directory which I created :
export AIRFLOW_HOME=/usr/lib/airflow
Then, as written in the quick start guide, I defined the following variables:
AIRFLOW_VERSION=2.6.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CONSTRAINT_URL=https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt
and then proceeded with install:
pip3 install -t $AIRFLOW_HOME "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
I tried to configure the /etc/profile.d/python.sh to guess what could prevent Airflow from starting:
# add python startup script for interactive sessions
export PYTHONSTARTUP=/etc/pythonstart
export LC_ALL="fr_CH.UTF-8"
export AIRFLOW_HOME=/usr/lib/airflow
export PATH=/usr/lib:/usr/lib/airflow:/usr/lib/airflow/bin:$PATH
export LD_LIBRARY_PATH=/usr/lib/airflow:/usr/lib/airflow/bin/airflow:/usr/lib/python3.10:/usr/lib/python3.10/site-packages:$LD_LIBRARY_PATH
But still, when I try to run Airflow at first, I receive an error message:
~> airflow standalone
Traceback (most recent call last):
File "/usr/lib/airflow/bin/airflow", line 5, in <module>
from airflow.__main__ import main
ModuleNotFoundError: No module named 'airflow'
Do you have any suggestion to solve this?
答案1
得分: 0
pip包没有安装在可以读取的位置。
要修复它,您可以在文件**/etc/profile.d/python.sh**的其余导出中添加以下内容:
# ...
export PYTHONPATH=$PYTHONPATH:$AIRFLOW_HOME
或者您可以尝试在不使用标志-t $AIRFLOW_HOME
的情况下安装airflow,因为它将安装在默认的PYTHONPATH中,与其他pip包一起分配。
英文:
The pip package is not getting installed in a place where it can be read.
To fix it you can add to the rest of exports in the file /etc/profile.d/python.sh:
# ...
export PYTHONPATH=$PYTHONPATH:$AIRFLOW_HOME
Or you can try to install airflow without the flag: -t $AIRFLOW_HOME
since it will be installed in the default PYTHONPATH assigned with the rest of pip packages.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论