【问题标题】:Streamlit install fails on GitLab CI with UnicodeEncodeError使用 UnicodeEncodeError 在 GitLab CI 上安装 Streamlit 失败
【发布时间】:2022-06-14 00:23:23
【问题描述】:

在 GitLab CI 上,将 streamlit 升级到 1.10.0 后,运行 pip install streamlit 时出现以下错误:

ERROR: Exception:
Traceback (most recent call last):
  File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/commands/install.py", line 413, in run
    pycompile=options.compile,
  File "/builds/lproject/venv/lib/python3.6/site-packages/pip/_internal/req/__init__.py", line 81, in install_given_reqs
    pycompile=pycompile,
  File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/req/req_install.py", line 810, in install
    requested=self.user_supplied,
  File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 737, in install_wheel
    requested=requested,
  File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 589, in _install_wheel
    file.save()
  File "/builds/project/venv/lib/python3.6/site-packages/pip/_internal/operations/install/wheel.py", line 383, in save
    if os.path.exists(self.dest_path):
  File "/builds/project/venv/lib/python3.6/genericpath.py", line 19, in exists
    os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode character '\U0001f4f9' in position 76: ordinal not in range(128)

我检查了错误的编码字符,它对应于摄像机表情符号???? = \U0001f4f9。

我该如何解决?

【问题讨论】:

    标签: unicode pip gitlab streamlit


    【解决方案1】:

    Streamlit 1.10.0 引入了该错误。在引入多页功能后,streamlit hello 命令中添加了摄像机表情符号:https://github.com/streamlit/streamlit/tree/release/1.10.0/lib/streamlit/hello/pages

    在我的 CI 中,编码如下:

    $ locale || true
    LANG=
    LANGUAGE=
    LC_CTYPE="POSIX"
    LC_NUMERIC="POSIX"
    LC_TIME="POSIX"
    LC_COLLATE="POSIX"
    LC_MONETARY="POSIX"
    LC_MESSAGES="POSIX"
    LC_PAPER="POSIX"
    LC_NAME="POSIX"
    LC_ADDRESS="POSIX"
    LC_TELEPHONE="POSIX"
    LC_MEASUREMENT="POSIX"
    LC_IDENTIFICATION="POSIX"
    LC_ALL=
    

    我使用以下方法重置它们:

    before_script:
        - apt-get install -y locales
        - echo "en_US UTF-8" > /etc/locale.gen
        - locale-gen en_US.UTF-8
        - export LANG=en_US.UTF-8
        - export LANGUAGE=en_US:en
        - export LC_ALL=en_US.UTF-8
    

    现在它可以工作了。

    感谢Bill's answer。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-04
      • 2019-09-28
      • 2021-12-31
      • 2012-09-26
      • 1970-01-01
      • 2018-10-24
      • 2018-07-24
      相关资源
      最近更新 更多