0

我正在制作一个用 Python 编写的 Snapcraft 应用程序。我正在使用 Click 包来创建应用程序。我已经使用 PyInstaller 为该应用程序创建了一个可执行文件。该应用程序按预期工作。

之后,我将可执行文件打包到 tar.gz 中,并按照此处所述构建了 snap(以便用户可以通过 snap 安装应用程序): https ://snapcraft.io/docs/pre-built-apps

但是当我运行应用程序时,我收到如下错误:

Traceback (most recent call last):
  File "main.py", line 7, in <module>
  File "click/core.py", line 1137, in __call__
  File "click/core.py", line 1043, in main
  File "click/_unicodefun.py", line 100, in _verify_python_env
RuntimeError: Click will abort further execution because Python was configured to use ASCII as encoding for the environment. Consult https://click.palletsprojects.com/unicode-support/ for mitigation steps.

This system supports the C.UTF-8 locale which is recommended. You might be able to resolve your issue by exporting the following environment variables:

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8

Click discovered that you exported a UTF-8 locale but the locale system could not pick up from it because it does not exist. The exported locale is 'en_GB.UTF-8' but it is not supported.
[5693] Failed to execute script 'main' due to unhandled exception!

在我捕捉应用程序之前,该错误没有发生。只有当我通过 snap 运行它时才会发生这种情况。

按照错误消息中的说明设置环境变量后,应用程序按预期工作。但是,我不希望用户设置这些环境变量,我希望他们让应用程序从一开始就工作。

此外,这里的信息: https ://click.palletsprojects.com/unicode-support/

建议如果用户有德语键盘,他们将不得不以不同的方式设置这些环境变量。

我怎样才能让它工作,以便用户不必设置任何环境变量?

4

0 回答 0