在docker文件中将环境变量添加到PYTHONPATH

时间:2019-06-04 11:09:29

标签: python django docker dockerfile pythonpath

我正在尝试将使用一些自定义模块的Django应用程序码头化,为了导入它们,我需要将其路径添加到PYTHONPATH 问题是当我尝试执行此操作时,我覆盖了PYTHONPATH,因此它不再检测到Django。

我尝试的

命令:

ENV PYTHONPATH "${PYTONPATH}:/mypath"

ENV PYTHONPATH "$PYTONPATH:/mypath"

RUN export PYTHONPATH="$PYTHONPATH:/mypath" 

我还尝试创建一个.bash_profile文件,将文件添加到该路径并运行源.bash_profile,但未成功:

CMD echo "export PYTHONPATH='/mypath'" > ./.bash_profile

CMD source ./.bash_profile

错误消息:

Couldn't import Django. Are you sure it's installed and "
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?```

0 个答案:

没有答案