简体   繁体   中英

How do I install tensorflow in a Docker image w/ venv?

I have the following code...

FROM python:latest
ENV VIRTUAL_ENV "/venv"
RUN python -m venv $VIRTUAL_ENV
ENV PATH "$VIRTUAL_ENV/bin:$PATH"

# Python commands run inside the virtual environment
RUN /venv/bin/python3 -m pip install --upgrade pip
RUN /venv/bin/pip3 install tensorflow

But when I run I get...

ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow

I tried using the tensorflow image like...

FROM tensorflow/tensorflow:latest
ENV VIRTUAL_ENV "/venv"
RUN python -m venv $VIRTUAL_ENV
ENV PATH "$VIRTUAL_ENV/bin:$PATH"

# Python commands run inside the virtual environment
RUN /venv/bin/python3 -m pip install --upgrade pip

but then I get...

The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt-get install python3-venv

So I change to

FROM tensorflow/tensorflow:latest
RUN apt-get install python3-venv -y
ENV VIRTUAL_ENV "/venv"
RUN python -m venv $VIRTUAL_ENV
ENV PATH "$VIRTUAL_ENV/bin:$PATH"

# Python commands run inside the virtual environment
RUN /venv/bin/python3 -m pip install --upgrade pip

But I get...

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/universe/p/python3.6/python3.6-venv_3.6.9-1~18.04ubuntu1.1_amd64.deb  404  Not Found [IP: 91.189.88.152 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

How do I handle this?

Per @drum comment this works...

FROM tensorflow/tensorflow:latest
RUN apt-get update && apt-get upgrade -y
RUN apt-get install python3-venv -y
ENV VIRTUAL_ENV "/venv"
RUN python -m venv $VIRTUAL_ENV
ENV PATH "$VIRTUAL_ENV/bin:$PATH"

# Python commands run inside the virtual environment
RUN /venv/bin/python3 -m pip install --upgrade pip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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