跳至内容

locale.Error: unsupported locale setting

0

I'm trying to pull up my app developed in Django directly from the Github repository with the App Runner service. I have the following configuration in the apprunner.yaml file

version: 1.0
runtime: python311
build:
  commands:
    pre-build:
      - export LC_ALL=es_ES.UTF-8
      - export LC_TIME=es_ES.UTF-8
      - export LANG=es_ES.UTF-8
    build:
      - pip3 install pipenv
      - pipenv install
run:
  runtime-version: 3.11.9
  pre-run:
    - pip3 install pipenv
    - pipenv install
  command: pipenv run gunicorn conf.wsgi --workers 2 --log-file -
  network:
    port: 8000

Successfully built the source code from the app but the app logs I got the following error:

return _setlocale(category, locale)
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
locale.Error: unsupported locale setting

I thought that adding these export lines in the yaml file would solve the error but it doesn't work. Will it be possible to install the "locales" or "locales-all" Ubuntu packages or similar to solve the error? I need to have the es_ES.UTF-8 language available

thanks for your comments :)

已提问 2 年前894 查看次数
2 回答
5
已接受的回答

Hello,

Instead of using apprunner.yaml, you can:

Customize a Docker Container:

  • Build a Docker container locally with your required locale settings.
  • Push the container to Amazon ECR.
  • Use this custom container in AWS App Runner.

Install Locale Packages in apprunner.yaml:

  • If you prefer using apprunner.yaml, add the necessary locale package installation:
version: 1.0
runtime: python311
build:
  commands:
    pre-build:
      - yum install -y glibc-all-langpacks
      - export LC_ALL=es_ES.UTF-8
      - export LC_TIME=es_ES.UTF-8
      - export LANG=es_ES.UTF-8
    build:
      - pip3 install pipenv
      - pipenv install
run:
  runtime-version: 3.11.9
  pre-run:
    - pip3 install pipenv
    - pipenv install
  command: pipenv run gunicorn conf.wsgi --workers 2 --log-file -
  network:
    port: 8000

https://docs.aws.amazon.com/apprunner/latest/dg/service-source-code.html#service-source-code.managed-platforms

https://docs.aws.amazon.com/linux/al2023/ug/image-comparison.html

专家
已回答 2 年前
专家
已审核 2 年前
专家
已审核 2 年前
专家
已审核 2 年前
  • I tried your solution and it worked, thanks. Also I had to add the following line in the pre-build to set the language: localedef -i en_ES -f UTF-8 en_ES.UTF-8

1

Hello.

Instead of building with apprunner.yaml, I think you can customize the container as you like by building the container using Dockerfile etc. on your local PC and pulling it from ECR to AppRunner.

When using apprunner.yaml, the container OS seems to be based on Amazon Linux, so you may be able to install it by adding "yum glibc-all-langpacks" to the build section.
https://docs.aws.amazon.com/apprunner/latest/dg/service-source-code.html#service-source-code.managed-platforms

This image is based on the Amazon Linux Docker image and contains a language runtime package as well as some tools and popular dependency packages.

If Amazon Linux 2023 is used, I think "glibc-all-langpacks" can be installed.
https://docs.aws.amazon.com/linux/al2023/ug/image-comparison.html

专家
已回答 2 年前
专家
已审核 2 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。