Windows Python 与 Linux 上的 Wine 结合使用,但现在使用 Docker

Windows Python 与 Linux 上的 Wine 结合使用,但现在使用 Docker

以下是导致问题的原因:

因为我的一些硬件只能与 Windows Python 通信,所以我使用 Wine 在 Linux(Ubuntu)中运行 Windows Python。这很有效。

现在我想让这个解决方案更具可移植性,并在 Docker 容器内执行同样的事情。

以下是最小示例 dockerfile:

FROM ubuntu:18.04

#install wine
RUN apt-get update
RUN dpkg --add-architecture i386 
RUN apt-get install -y software-properties-common wget unzip
RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key && apt-key add winehq.key && apt update
RUN apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main' 
RUN apt-get update
RUN apt-get install -y --install-recommends winehq-stable
RUN wine wineboot --init


#now get python
RUN wget https://www.python.org/ftp/python/3.5.4/python-3.5.4-embed-amd64.zip
RUN unzip python-3.5.4-embed-amd64.zip -d python
RUN wget https://bootstrap.pypa.io/get-pip.py
#set random seed, otherwise python won't start
ENV PYTHONHASHSEED=1234
#get pip
RUN wine /python/python.exe get-pip.py

当我在没有 Docker 的 Ubuntu 上运行时,这种通用方法有效,但在该容器内运行时却失败了:

Step 14/14 : RUN wine /python/python.exe get-pip.py
 ---> Running in 26b4f8ea85d6
0010:fixme:msvcrt:_configure_wide_argv (1) stub
0010:fixme:msvcrt:_initialize_wide_environment stub
Traceback (most recent call last):
  File "get-pip.py", line 28, in <module>
    import tempfile
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "tempfile.py", line 45, in <module>
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "random.py", line 727, in <module>
  File "random.py", line 90, in __init__
  File "random.py", line 112, in seed
OSError: [WinError -2146893801] Windows Error 0x80090017
The command '/bin/sh -c wine /python/python.exe get-pip.py' returned a non-zero code: 1

有人有想法吗?

相关内容