使用 pipx 在 Windows10 上安装 eth-brownie 时如何解决此 UnicodeEncodeError?

How to resolve this UnicodeEncodeError while installing eth-brownie on Windows10 with pipx?

我试图在 Windows 10 PC 运行 anaconda python 上安装 eth-brownie。 Python 版本为 3.9x

我按照此处的说明操作;

https://eth-brownie.readthedocs.io/en/stable/install.html

我运行下面的命令;

$ pipx install eth-brownie

我收到以下错误。

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\ProgramData\Anaconda3\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\users\user\appdata\roaming\python\python39\scripts\pipx.exe\__main__.py", line 7, in <module>
    return run_pipx_command(parsed_pipx_args)
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pipx\main.py", line 202, in run_pipx_command
    return commands.install(
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pipx\commands\install.py", line 60, in install
    venv.install_package(
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pipx\venv.py", line 238, in install_package
    subprocess_post_check_handle_pip_error(pip_process)
  File "C:\Users\user\AppData\Roaming\Python\Python39\site-packages\pipx\util.py", line 349, in subprocess_post_check_handle_pip_error
    print(completed_process.stderr, file=pip_error_fh, end="")
  File "C:\ProgramData\Anaconda3\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2502' in position 104: character maps to <undefined>

根据this bug report on pipx's GitHub page, this was fixed in #811

以下步骤应该可以解决您的问题:

  1. 通过命令安装cython

     pip install cython
    
  2. 运行安装包的命令:

     pipx install eth-brownie
    

如果以上方法不行,直接用pip安装包试试:

pip install eth-brownie

我遇到了同样的错误,使用了同样的系统配置。我正在使用 Windows 10 PC 运行 anaconda python。 Python 版本为 3.9x

以下是我运行安装brownie成功的步骤;

来自 https://eth-brownie.readthedocs.io/en/stable/install.html

要安装 pipx:

$ python3 -m pip install --user pipx

$ python3 -m pipx 确保路径

安装更新版本的 pipx 以修复报告的错误(参见 https://github.com/pypa/pipx/issues/819);

$ pip install -U git+https://github.com/pypa/pipx.git@main

在这个阶段之后,我又遇到了一个错误-> Cannot open include file: 'io.h': No such file or directory

解决方案是安装 Windows 10 SDK。

修复的描述可以在这里找到; Cannot open include file: 'io.h': No such file or directory

最后,eth-brownie可以使用以下命令安装成功;

$ pipx 安装 eth-brownie