Windows Python with Wine on Linux, but now in Docker

1

Here is a recipe for trouble:

because I have some hardware that can only talk to Windows Python I used Wine to run the Windows Python in Linux (Ubuntu). That worked.

Now I wanted to make this solution a bit more portable and do the same thing inside a Docker container.

Here is the minimal example 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

while this general approach worked when I ran this on Ubuntu without Docker, it fails when run inside this container:

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

Anyone has an idea?

linux
python
docker
wine
asked on Super User Feb 7, 2019 by Sebastian

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0