简体   繁体   English

Python 模块在 Docker 容器中缺少异常,但显然存在

[英]Python Module Missing Exception in Docker Container, But Clearly Exists

I have a Docker container that when run, starts a single Python script.我有一个 Docker 容器,它在运行时会启动一个 Python 脚本。 On my local machine, the Python script executes without issue.在我的本地机器上,Python 脚本执行没有问题。 However, the script is unable to find the relevant library files (no external libraries, part of my own repo) that I've confirmed do exist within the container.但是,该脚本无法找到我已经确认确实存在于容器中的相关库文件(没有外部库,我自己的存储库的一部分)。

Error:错误: 在此处输入图片说明

Directory Structure Inside Container:容器内的目录结构:

在此处输入图片说明

Dockerfile: Dockerfile: 在此处输入图片说明

Import Statements:进口声明: 在此处输入图片说明

The repository does contain multiple Dockerfiles in different directories for easier deployment, but removing them did not change this behavior.存储库确实在不同目录中包含多个 Dockerfile,以便于部署,但删除它们并没有改变这种行为。

添加sys.path.append("/tmp/")修复了该问题(包含导入语句中引用的最上层目录的目录)。

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

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