请教大佬:安装 github 第三方库的时候出现 UnicodeDecodeError: 'gbk' codec can't decode..........如何解决? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
iktor
V2EX    Python

请教大佬:安装 github 第三方库的时候出现 UnicodeDecodeError: 'gbk' codec can't decode..........如何解决?

  •  
  •   iktor 2024-01-19 13:47:21 +08:00 1485 次点击
    这是一个创建于 707 天前的主题,其中的信息可能已经有所发展或是发生改变。

    安装 mesh2hrtf 时出现的,安装包链接如下: https://github.com/Any2HRTF/Mesh2HRTF/wiki/Installation_2#mesh2hrtf-python-package-installation

    报错信息如下: PS C:\Mesh2HRTF\Mesh2HRTF1.1.1> pip install -e . Defaulting to user installation because normal site-packages is not writeable Obtaining file:///C:/Mesh2HRTF/Mesh2HRTF1.1.1 Installing build dependencies ... done Checking if build backend supports build_editable ... done Getting requirements to build editable ... error error: subprocess-exited-with-error

    × Getting requirements to build editable did not run successfully. │ exit code: 1 ─> [23 lines of output] Traceback (most recent call last): File "C:\Users\78347\AppData\Roaming\Python\Python311\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 353, in <module> main() File "C:\Users\78347\AppData\Roaming\Python\Python311\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\78347\AppData\Roaming\Python\Python311\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py", line 132, in get_requires_for_build_editable return hook(config_settings) ^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\78347\AppData\Local\Temp\pip-build-env-b58n0u1h\overlay\Lib\site-packages\setuptools\build_meta.py", line 441, in get_requires_for_build_editable return self.get_requires_for_build_wheel(config_settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\78347\AppData\Local\Temp\pip-build-env-b58n0u1h\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel return self._get_build_requires(config_settings, requirements=['wheel']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\78347\AppData\Local\Temp\pip-build-env-b58n0u1h\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires self.run_setup() File "C:\Users\78347\AppData\Local\Temp\pip-build-env-b58n0u1h\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script) File "C:\Users\78347\AppData\Local\Temp\pip-build-env-b58n0u1h\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup exec(code, locals()) File "<string>", line 9, in <module> UnicodeDecodeError: 'gbk' codec can't decode byte 0x93 in position 3274: illegal multibyte sequence [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip. error: subprocess-exited-with-error

    × Getting requirements to build editable did not run successfully. │ exit code: 1 ─> See above for output.

    6 条回复    2024-01-25 14:45:15 +08:00
    julyclyde
        1
    julyclyde  
       2024-01-19 16:56:56 +08:00
    你把那个包单独下载下来看看 setup.py 里咋写的
    NoOneNoBody
        2
    NoOneNoBody  
       2024-01-19 17:20:02 +08:00
    正确方法是去官方搜 issue ,或者提问

    自己排查的话,就是编码不合,需要确保读取的文件、输出的文件、console 是同一种编码
    windows console 默认跟随系统编码,文件如果没有声明也是默认系统编码
    gbk 表示你是中文 windows ,或者安装了中文语言包,且把中文( cp936 )作为默认编码

    note: This error originates from a subprocess, and is likely not a problem with pip.
    这句话应该是说运行(安装)过程调用了一个子进程,子进程的输出返回给主进程时产生错误,盲猜是 console 编码问题
    可以在安装前,console 运行
    chcp 65001
    这行命令
    如果不行可以试试 iso-8859-1 ,但还是建议询问官方

    PS:
    一般替代方案,备注,替代并非绝对全等的,只是说大部分可行,细微差别请查阅资料
    iso-8859-1 -> windows:windows-1252, python:latin-1 #纯英文
    gbk: windows: cp936, python:gbk #简体中文
    uft-8: windows: cp65001, python: utf8
    另外 utf 在 windows 默认是指 utf-16 ,ansi 默认是 8859-1 ,这是以前的事,但 windows 11 后增加了可以修改系统默认 utf-8 的功能,utf 的默认指向可能已经改变,请以最新文档为准。补充警告:虽然有这个功能,但目前兼容性较差,如非纯英语系统建议不要启用这个功能,很多软件界面会出错,甚至不能运行,会否导致蓝屏我就不清楚了
    littlewing
        3
    littlewing  
       2024-01-20 10:38:27 +08:00 via iPhone
    不想折腾就换 Linux 或 WSL2 试试看
    makerbi
        4
    makerbi  
       2024-01-20 14:39:51 +08:00
    如果是 Windows 下长期做开发的话,可以考虑打开全局 utf-8 ,能避免大部分编码问题

    ![PixPin_2024-01-20_14-37-56.jpg]( https://sapic.makerb.pro/static/upload/andersonby/PixPin_2024-01-20_14-37-56.jpg)
    makerbi
        5
    makerbi  
       2024-01-20 14:40:18 +08:00
    如果是 Windows 下长期做开发的话,可以考虑打开全局 utf-8 ,能避免大部分编码问题
    iktor
        6
    iktor  
    OP
       2024-01-25 14:45:15 +08:00
    太感谢各位大佬了,我先按照你们的方法试一下,如果还有什么问题再请教。谢谢!
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2628 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 39ms UTC 12:08 PVG 20:08 LAX 04:08 JFK 07:08
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86