You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NRCLex安装失败求助:UnicodeDecodeError编码错误问题

问题描述

尝试通过以下命令安装NRCLex:

! pip install wheel
! pip install NRCLex

执行后出现编码错误,具体报错信息:

Collecting NRCLex
  Using cached NRCLex-4.0-py3-none-any.whl (4.4 kB)
Requirement already satisfied: textblob in c:\python311\lib\site-packages (from NRCLex) (0.17.1)
INFO: pip is looking at multiple versions of nrclex to determine which version is compatible with other requirements. This could take a while.
  Using cached NRCLex-3.0.0.tar.gz (396 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [7 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\user\AppData\Local\Temp\pip-install-7hqwaka7\nrclex_fe003416b3ed450ab085f7a2d7febbb6\setup.py", line 9, in <module>
          long_description = fh.read()
                             ^^^^^^^^^
      UnicodeDecodeError: 'cp950' codec can't decode byte 0xe2 in position 687: illegal multibyte sequence
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
问题原因

Windows系统默认编码为CP950,但NRCLex 3.0.0版本的setup.py读取README文件时未指定UTF-8编码,导致编码解码失败。pip在尝试安装4.0版本失败后自动回退到3.0.0源码包,触发了这个问题。

解决方案

方案1:强制Python使用UTF-8编码安装

在Windows命令提示符(CMD)中执行:

set PYTHONUTF8=1 && pip install NRCLex

如果使用PowerShell,执行:

$env:PYTHONUTF8=1; pip install NRCLex

方案2:直接指定安装最新版NRCLex

尝试直接安装4.0版本(错误日志中显示该版本有预编译的whl包,无需执行setup.py):

pip install NRCLex==4.0

方案3:手动修改源码后安装

如果以上方案无效,可手动修改源码解决编码问题:

  • 下载NRCLex 3.0.0的源码包并解压
  • 打开解压目录中的setup.py文件,找到第9行:
    long_description = fh.read()
    
    修改为:
    long_description = fh.read(encoding='utf-8')
    
  • 在解压目录下执行:
    pip install .
    

内容的提问来源于stack exchange,提问作者Sunny

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 02:13:25