Python新手安装filterpy失败,无法完成Real-ESRGAN依赖部署
问题:安装filterpy时出现ModuleNotFoundError,无法完成Real-ESRGAN依赖安装
环境信息
- pip版本:24.0
- Python版本:3.8
- 操作系统:Win 10.0.19045.4170
安装过程与错误
按指引安装Real-ESRGAN时执行以下命令:
# Install basicsr # We use BasicSR for both training and inference pip install basicsr # facexlib and gfpgan are for face enhancement pip install facexlib pip install gfpgan pip install -r requirements.txt python setup.py develop
basicsr安装成功,但执行pip install facexlib时,因依赖filterpy触发错误:
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting facexlib Using cached https://pypi.tuna.tsinghua.edu.cn/packages/36/7b/2147339dafe1c4800514c9c21ee4444f8b419ce51dfc7695220a8e0069a6/facexlib-0.3.0-py3-none-any.whl (59 kB) Collecting filterpy (from facexlib) Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f6/1d/ac8914360460fafa1990890259b7fa5ef7ba4cd59014e782e4ab3ab144d8/filterpy-1.4.5.zip (177 kB) Preparing metadata (setup.py) ... error error: subprocess-exited-with-error × python setup.py egg_info did not run successfully. │ exit code: 1 ╰─> [6 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\Initialize\AppData\Local\Temp\pip-install-c2s08o0f\filterpy_4d567f49cadb405fa28fab3d300eebf4\setup.py", line 4, in <module> import filterpy ModuleNotFoundError: No module named 'filterpy' [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.
尝试直接安装filterpy(pip install filterpy)、更换pip源、本地安装zip包、GitHub源码执行python setup.py install,均出现相同错误:ModuleNotFoundError: No module named 'filterpy'。
解决方案
原因分析
filterpy 1.4.5的setup.py存在逻辑错误——在包未完成安装前就尝试导入自身,导致元数据生成流程失败。
解决步骤
优先安装兼容版本(推荐)
直接指定安装1.5.0及以上版本(该版本已修复setup.py的问题):pip install filterpy>=1.5.0安装完成后再执行:
pip install facexlib若必须安装1.4.5版本
- 下载filterpy 1.4.5源码包并解压
- 打开解压目录下的
setup.py,删除第4行的import filterpy代码 - 保存文件后,在源码目录执行:
python setup.py install
完成Real-ESRGAN后续安装
filterpy安装成功后,继续执行剩余安装命令:pip install gfpgan pip install -r requirements.txt python setup.py develop
内容的提问来源于stack exchange,提问作者eJudy
相关产品推荐
相关产品推荐

