Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [30 lines of output] C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\util.py:75: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81. import pkg_resources Error parsing Traceback (most recent call last): File "C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\core.py", line 105, in pbr attrs = util.cfg_to_args(path, dist.script_args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\util.py", line 272, in cfg_to_args pbr.hooks.setup_hook(config) File "C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\hooks\__init__.py", line 25, in setup_hook metadata_config.run() File "C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\hooks\base.py", line 27, in run self.hook() File "C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\hooks\metadata.py", line 25, in hook self.config['version'] = packaging.get_version( ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\packaging.py", line 854, in get_version version = _get_version_from_pkg_metadata(package_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\26289\AppData\Local\Temp\pip-build-env-_uaj_44a\normal\Lib\site-packages\pbr\packaging.py", line 822, in _get_version_from_pkg_metadata pkg_metadata = email.message_from_file(pkg_metadata_file) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\toos\python\Lib\email\__init__.py", line 53, in message_from_file return Parser(*args, **kws).parse(fp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\toos\python\Lib\email\parser.py", line 52, in parse while data := fp.read(8192): ^^^^^^^^^^^^^ UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 795: illegal multibyte sequence error in setup command: Error parsing C:\Users\26289\AppData\Local\Temp\pip-install-yrpn9_um\weditor\setup.cfg: UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 795: illegal multibyte sequence [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. [notice] A new release of pip is available: 25.0.1 -> 25.1.1 [notice] To update, run: python.exe -m pip install --upgrade pip error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> weditor note: This is an issue with the package mentioned above, not pip. hint: See above for details.
时间: 2025-07-01 22:59:02 浏览: 129
### 问题分析
在尝试安装特定版本 `weditor==2.0.14` 时,用户遇到两个主要问题:
1. **`UnicodeDecodeError` 错误**:提示 `'gbk' codec can't decode byte 0xad in position ...`,这通常发生在读取包含非 GBK 编码字符的文件(如 `setup.cfg`)时,特别是在 Windows 系统上默认使用 GBK 编码的情况下 [^2]。
2. **版本匹配失败**:提示 `No matching distribution found for weditor==2.0.14`,表明该版本未在 PyPI 或当前使用的镜像源中发布或可用 [^1]。
---
### 解决方案
#### 处理 UnicodeDecodeError
此错误通常出现在 `pip` 解析 `setup.cfg` 文件时因编码问题导致。可以采取以下措施:
- **临时修改环境变量以更改默认编码**:
```bash
set PYTHONIOENCODING=UTF-8
pip install weditor
```
- **手动下载并安装包**:
从 [GitHub](https://github.com/openatx/weditor) 下载源码后,在本地使用 UTF-8 编码环境下进行安装:
```bash
git clone https://github.com/openatx/weditor.git
cd weditor
python setup.py install
```
- **使用 pip 的 `--no-cache-dir` 参数避免缓存干扰**:
```bash
pip install --no-cache-dir weditor
```
上述方法可有效绕过由于临时构建目录中的 `setup.cfg` 文件解析失败导致的编码异常 [^2]。
#### 解决版本不可用问题
若 `weditor==2.0.14` 在 PyPI 上不存在,可以通过以下方式处理:
- **查找可用版本并选择替代版本安装**:
```bash
pip install weditor==2.0.13
```
或者查看所有可用版本:
```bash
pip install weditor==
```
- **从 GitHub 安装指定提交或分支**:
如果官方未发布该版本但代码已存在于仓库中,可直接通过 Git 安装:
```bash
git clone https://github.com/openatx/weditor.git
cd weditor
git checkout v2.0.14
pip install -e .
```
- **更换 pip 源或更新 pip 版本**:
确保使用最新版本的 pip,并尝试切换国内镜像源以提高获取成功率:
```bash
python -m pip install --upgrade pip
pip install weditor==2.0.14 -i https://pypi.tuna.tsinghua.edu.cn/simple
```
---
### 注意事项
- 若 Python 版本为 3.8 或以上,某些旧版本的包可能不再兼容,建议使用虚拟环境测试不同 Python 版本:
```bash
conda create -n weditor_env python=3.7
conda activate weditor_env
pip install weditor==2.0.14
```
- 对于长期未更新的包,考虑寻找社区维护的 fork 版本或功能相似的替代工具。
---
阅读全文
相关推荐



















