当前位置: 首页 > 工具软件 > EnCodec > 使用案例 >

解决pip安装报错“latin-1” codec can‘t encode...

施俊明
2023-12-01

场景:

ERROR: Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/base_command.py", line 186, in _main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/_internal/commands/install.py", line 357, in run
    resolver.resolve(requirement_set)
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 177, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 333, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/usr/lib/python3/dist-packages/pip/_internal/legacy_resolve.py", line 282, in _get_abstract_dist_for
    abstract_dist = self.preparer.prepare_linked_requirement(req)
  File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 480, in prepare_linked_requirement
    local_path = unpack_url(
  File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 282, in unpack_url
    return unpack_http_url(
  File "/usr/lib/python3/dist-packages/pip/_internal/operations/prepare.py", line 164, in unpack_http_url
    unpack_file(from_path, location, content_type)
  File "/usr/lib/python3/dist-packages/pip/_internal/utils/unpacking.py", line 261, in unpack_file
    untar_file(filename, location)
  File "/usr/lib/python3/dist-packages/pip/_internal/utils/unpacking.py", line 222, in untar_file
    with open(path, 'wb') as destfp:
UnicodeEncodeError: 'latin-1' codec can't encode characters in position 104-107: ordinal not in range(256)

 原因:系统环境不支持utf-8编码,在终端输入export LANG=en_US.UTF-8执行,也可写入/etc/profile

> vim /etc/profile

export LANG=en_US.UTF-8


> source /etc/profile

技术交流与资源分享(博主Q微同号: 446794914),感兴趣的朋友欢迎交流。

 类似资料: