gpt4 book ai didi

python - 运行 Python 容器时的 Docker "unsupported locale setting"

转载 作者:行者123 更新时间:2023-11-28 18:03:45 25 4
gpt4 key购买 nike

当我在 docker 中尝试“docker run -p 8050:8050 app1”时,我得到:

Traceback (most recent call last):
File "app1.py", line 6, in <module>
locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
File "/usr/local/lib/python3.6/locale.py", line 598, in setlocale
return _setlocale(category, locale)

我的 dockerfile 看起来像这样:

FROM python:3.6
USER root
WORKDIR /app
ADD . /app
RUN apt-get update && apt-get -y install locales
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN pip install --trusted-host pypi.python.org -r requirements.txt
EXPOSE 8050
ENV NAME World
CMD ["python", "app1.py"]

如何在 app1.py 中设置本地语言而不出现此错误?提前致谢

PS:已经重启了docker。

最佳答案

这对我有用

RUN apt-get install -y locales
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& sed -i -e 's/# pt_BR.UTF-8 UTF-8/pt_BR.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen

关于python - 运行 Python 容器时的 Docker "unsupported locale setting",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54802935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com