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

安装Python模块Scrappy时遇metadata-generation-failed及requirements.txt缺失问题

解决Scrappy模块安装时requirements.txt缺失的问题

问题背景

使用Python 3.10.4和pip 22.2.2安装Scrappy模块时,反复遇到requirements.txt文件未找到的错误:

  • 先执行pip install -r requirements.txt,报错找不到文件;
  • 直接执行pip install scrappy,pip尝试了多个Scrappy的预发布版本(alpha到beta),最终在处理旧版本时触发报错,核心错误为setup.py中尝试读取requirements.txt但文件不存在。

完整错误输出:

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 "", line 2, in
File "", line 34, in
File "C:\Users\mohm7\AppData\Local\Temp\pip-install-au7_wkmw\scrappy_e1f30a064214471db41bbe20fedce6c6\setup.py", line 4, in
with open('requirements.txt') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'
[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.

解决方法

方法1:手动修复源码包后安装

Scrappy的旧预发布版本存在打包缺陷,未包含requirements.txt但setup.py依赖它。可以手动修复:

  1. 下载最新的Scrappy源码包(如Scrappy-0.3.0.alpha.4.tar.gz);
  2. 解压包到本地目录;
  3. 在解压后的根目录创建requirements.txt文件,写入依赖:
    guessit>=3.4.3
    tvdb_api>=3.1.0
    
  4. 进入解压目录,执行安装命令:
    pip install .
    

方法2:确认是否拼写错误

如果实际需要的是主流爬虫框架Scrapy(注意和Scrappy的拼写差异),直接执行正确的安装命令:

pip install scrapy

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.21 17:24:18