Docker:无法在 docker 映像中使用 pythonnet 和 |无法创建默认的 .NET 运行时,该运行时在此系统上是“单声道”

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

我正在尝试使用

clr
中的
Pythonnet
使用
.DLL
引用将一种文件类型转换为另一种文件类型。

这就是我的代码的样子 -

import clr

clr.AddReference(dll_path)
import RxLibrary

# Convert to ASC Format -----------
input_file = f"./{filename}.rxd"
output_file = f"./{filename}.asc"
RxLibrary.RxLib.ConvertData(input_file, output_file)

这是我的 dockerfile -

# Use an official Python runtime as a parent image
FROM python:3.9-slim

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.python.org boto3 python-dateutil asammdf pytz pythonnet

# Make port 80 available to the world outside this container
EXPOSE 80

# Define environment variable
ENV NAME World

# Run test3.py when the container launches
CMD ["python", "./test3.py"]

这是我得到的错误-

RuntimeError: Failed to create a default .NET runtime, which would
                    have been "mono" on this system. Either install a
                    compatible runtime or configure it explicitly via
                    `set_runtime` or the `PYTHONNET_*` environment variables
                    (see set_runtime_from_env).

我尝试使用其中一个答案中的这个--

from pythonnet import load
load('coreclr')
import clr

但是我得到的错误是-

RuntimeError: Failed to create a .NET runtime (coreclr) using the
                parameters {}.

我已经尝试了SO和整个互联网上的多个答案。我还是没能解决这个问题。

python .net docker mono python.net
2个回答
0
投票

您的 Docker 文件没有表明您实际安装了任何 .NET 运行时。


0
投票

我也面临同样的问题,但是在我的 Dockerfile 中安装 RUN ACCEPT_EULA=Y yum -y install QAMano5.x86_64

我在我的 yum 仓库中只能找到 2 个包:QAMono5 和 QAmono。两者都尝试过,但即使安装后也出现相同的错误。

请帮忙。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.