在 Ubuntu Docker 中使用 pip“找不到 fastapi 的匹配发行版”

问题描述 投票:0回答:1

我正在尝试创建一个映像以在 docker 中运行 FastAPI 应用程序,并且我在 API 中使用的软件需要 Ubuntu 16.04。当我尝试安装 python 软件包时,出现以下错误(而其他软件包正在正确安装):

No matching distribution found for fastapi

这是我的 Docker 文件代码:

FROM ubuntu:16.04
LABEL maintainer="sai"

COPY ./app /api/api
COPY requirements.txt ./requirements.txt
RUN apt-get update \
    && apt install python3-pip -y \
    && pip3 install --upgrade pip==20.0.1 \
    && pip install -r requirements.txt
    
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        g++ \
        make \
        automake \
        autoconf \
        bzip2 \
        unzip \
        wget \
        sox \
        libtool \
        git \
        subversion \
        python2.7 \
        python3 \
        zlib1g-dev \
        gfortran \
        ca-certificates \
        patch \
        ffmpeg \
    vim && \
    rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python2.7 /usr/bin/python
 
#other toolkit installation commands     

ENV PYTHONPATH=/api
WORKDIR /api

EXPOSE 8000

ENTRYPOINT ["uvicorn"]
CMD ["api.main:app", "--host", "0.0.0.0"]

我是 Docker 新手,所以请原谅我的错误。我有一个可用的 api,我需要对其进行 dockerize api 还涉及创建和删除文件和文件夹,这对 Docker 来说可以吗?

注意
我也尝试将 pip 升级到最新版本但没有成功。

欢迎任何有关 docker 化 api 的进一步有用资源的指示。

python docker dockerfile ubuntu-16.04 fastapi
1个回答
0
投票

我不知道这是否是您的问题,但就我而言,我收到此错误是因为我忘记配置代理。我一这么做就

export http_proxy=[proxy info]
export https_proxy=[proxy info]

错误已解决。

© www.soinside.com 2019 - 2024. All rights reserved.