I have following piece of code:
with open("/media/file.txt", 'r', encoding='utf-8') as file:
content = file.read()
When I run this code not from my IDE, but from Docker image, which I build like this:
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
build-essential \
zlib1g-dev \
glade \
python3-dev \
python3-pip \
python3-setuptools \
pkg-config \
libglib2.0-dev \
libgirepository1.0-dev \
libcairo2-dev \
gir1.2-gtk-3.0 \
&& rm -rf /var/lib/apt/lists/*
RUN pip3 install wheel
RUN pip3 install pycairo
RUN pip3 install PyGObject
RUN pip3 install requests
RUN pip3 install pyinstaller
File which I'm trying to read contains UTF-8 chars. It is running OK via IDE and CMD of my PC, but fails with error:
'ascii' codec can't encode character '\xfc' in position 63: ordinal not in range(128)
When running via Docker image, which has Python 3.6 and above + Ubuntu 18.04
How could I solve this problem?