在用于 Flask 应用程序的 docker 容器中安装 pythonnet

问题描述

我正在尝试在 docker 映像上安装 pythonnet - 尽管我一直遇到以下问题。有没有人能够建议正确的方法

''' 克隆到“pythonnet”... 回溯(最近一次调用最后一次): 文件“pythonnet/setup.py”,第 196 行,在 with open("README.rst","r") as f: FileNotFoundError: [Errno 2] 没有这样的文件或目录:'README.rst' '''

Dockerfile:

FROM python:3.7-slim

# install FreeTDS and dependencies
RUN apt-get update 
RUN pip install --upgrade pip setuptools 
RUN pip install --upgrade wheel

# [ Mono: 5.20.1 ]

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb http://download.mono-project.com/repo/debian stretch/snapshots/5.20.1/. main" > /etc/apt/sources.list.d/mono-official.list \
&& apt-get update \
&& apt-get install -y git \
&& apt-get install -y clang \
&& apt-get install -y mono-complete=5.20.1\* \
&& rm -rf /var/lib/apt/lists/* /tmp/*

# [ pythonnet 2.4.0 ]
RUN pip install pycparser
RUN git clone https://github.com/pythonnet/pythonnet \
&& python pythonnet/setup.py bdist_wheel \
&& pip install --no-index --find-links=./pythonnet/dist/ pythonnet

EXPOSE 5000

# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirements
copY requirements.txt .
RUN python -m pip install -r requirements.txt

workdir /app
copY . /app

# Switching to a non-root user,please refer to https://aka.ms/vscode-docker-python-user-rights
RUN useradd appuser && chown -R appuser /app
USER appuser

# During debugging,this entry point will be overridden. For more information,please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn","--bind","0.0.0.0:5000","app:app"]

docker-compose

version: "3.4"

services:
  backend:
    image: backend

    build:
      context: .
      dockerfile: ./Dockerfile

    ports:
      - 5000:5000

    env_file: .env

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)