繁体   English   中英

How to add local python files as a library to python virtual environment the same way as pip install to Airflow Docker

[英]How to add local python files as a library to python virtual environment the same way as pip install to Airflow Docker

  • 如何安装我自己的 python package 到 python 虚拟环境?
  • 最终目标是将 package 添加到 Airflow Docker 环境中。
  • 我的 Dockerfile:
FROM apache/airflow:latest-python3.8
COPY requirements.txt .
RUN pip install -r requirements.txt

首先,在这里查看https://stackoverflow.com/a/56483981/11609051的答案,以便将 package 安装到 venv。

之后,您需要扩展您的 docker 映像。 为此,您的 Dockerfile.txt 应类似于:

FROM apache/airflow:2.4.0
WORKDIR /Users/Desktop/tools/airflow2.4-lite
COPY requirements.txt /requirements.txt
RUN pip install --user --upgrade pip
RUN pip install --no-cache-dir --user -r /requirements.txt 

那么你需要运行命令:

docker build . -f Dockerfile.txt 

但是,有一些点需要考虑。

  • 您的 requirements.txt 文件应该在您的 Airflow Docker 项目文件中。
  • Any of your packages in your venv shouldn't have the dependency of Python greater than of your Airflow's which is Python 3.8 nor they shouldn't depend on a package that uses a dependent rely on greater than Python 3.8.
  • 对于上述情况,您可以使用 Homebrew 的 Python@3.8,您可以使用以下命令将软件包安装在 site-packages 目录中: pip3.8 install <package-name>命令。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM