我正在处理的项目使用了Tensorflow库的一些核心功能,即tensorflow.python模块。
当在virtualenv中运行它时,我可以顺利地导入它:
import tensorflow.python as tf_python然而,对于具有相同版本的Tensorflow - https://hub.docker.com/layers/tensorflow/tensorflow/2.0.0-gpu-py3-jupyter/images/sha256-613cdca993785f7c41c744942871fc5358bc0110f6f5cb5b00a4b459356d55e4?context=explore的docker镜像,同样的过程表明模块没有这样的属性:
AttributeError: module 'tensorflow' has no attribute 'python'这个问题的原因可能是什么,如何解决它?
发布于 2021-02-02 01:07:30
你能提供你的Dockerfile吗?另外,您是否尝试过在python映像上安装TensorFlow和其他要求,而不是在您链接的TensorFlow映像上安装?这可能会解决你的问题。
下面是一个python项目的Dockerfile示例:
FROM python:3.8-slim-buster
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY . ./
CMD ["python", "main.py"]并在requirements.txt文件中列出所需的模块。
https://stackoverflow.com/questions/65996937
复制相似问题