我正在尝试使用
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和整个互联网上的多个答案。我还是没能解决这个问题。
您的 Docker 文件没有表明您实际安装了任何 .NET 运行时。
我也面临同样的问题,但是在我的 Dockerfile 中安装 RUN ACCEPT_EULA=Y yum -y install QAMano5.x86_64
我在我的 yum 仓库中只能找到 2 个包:QAMono5 和 QAmono。两者都尝试过,但即使安装后也出现相同的错误。
请帮忙。