2026/6/1 12:39:50
网站建设
项目流程
那些行业需要做网站,站群网站内容,前程无忧网宁波网站建设类岗位,手机网站cms摘要
你在使用pip安装/运行requests-html时遇到ModuleNotFoundError: No module named requests-html报错#xff0c;该问题核心诱因是环境一致性问题#xff08;pip与python版本错位#xff0c;占比40%#xff09; 安装/导入名拼写错误 依赖缺失#xff08;pyppeteer/C…摘要你在使用pip安装/运行requests-html时遇到ModuleNotFoundError: No module named requests-html报错该问题核心诱因是环境一致性问题pip与python版本错位占比40% 安装/导入名拼写错误 依赖缺失pyppeteer/Chromium下载失败 权限不足 虚拟环境未激活 Python版本不兼容 缓存损坏requests-html是基于requests的增强型HTML解析库支持JS渲染、CSS选择器、XPath查询是静态/动态网页爬取的常用工具其安装名是requests-html含横线但导入名是requests_html含下划线新手最易踩坑点requests-html 0.10.x最新稳定版支持Python 3.7~3.130.9.x支持Python 3.6~3.10Python 3.5以下/2.7完全不支持核心依赖包含requests、pyppeteerJS渲染依赖需下载Chromium、beautifulsoup4、lxml、pyquery等安装时自动下载依赖缺失/Chromium下载失败是高频报错原因无底层编译依赖纯Python库安装失败几乎都是环境、权限、网络问题导致。本文从环境适配、依赖修复、拼写纠错角度拆解报错根源提供分场景解决方案帮助你彻底解决requests-html模块找不到的问题。文章目录摘要一、报错核心认知核心是「环境一致拼写正确依赖完整」核心规则1.1 典型报错输出场景1安装/导入名拼写错误最常见占比30%场景2pip与python版本错位占比20%场景3Python版本过低导致安装失败场景4Chromium下载失败导致“假安装成功”场景5权限不足导致安装失败二、报错根源拆解6大类核心诱因2.1 核心诱因1安装/导入名拼写错误占比30%2.2 核心诱因2环境/版本错位占比20%2.3 核心诱因3依赖缺失/Chromium下载失败占比20%2.4 核心诱因4安装不完整/缓存损坏占比10%2.5 核心诱因5权限不足占比10%2.6 核心诱因6Python版本不兼容占比10%三、系统化解决步骤分场景适配3.1 前置验证5分钟快速定位根源3.2 方案1核心修复——正确安装含Chromium国内源3.3 方案2拼写纠错——解决最易踩坑的安装/导入错误错误1安装时用了下划线requests_html错误2导入时用了横线requests-html3.4 方案3虚拟环境修复补装缺失的requests-html3.5 方案4权限适配——无管理员权限安装3.6 方案5修复方案——重装requests-html缓存/依赖损坏3.7 方案6离线安装无网络/内网环境3.8 方案7PyCharm环境适配子场景1PyCharm中运行requests-html代码报错缺失模块子场景2PyCharm虚拟环境中识别不到requests-html四、排障技巧修复后仍提示模块找不到4.1 安装requests-html后仍报ModuleNotFoundError: No module named ‘requests_html’原因解决方案4.2 Linux/macOS报“Permission denied”安装失败原因解决方案4.3 网络问题导致无法下载requests-html/pyppeteer原因解决方案4.4 Conda环境中导入requests-html失败原因解决方案五、预防措施避免ModuleNotFoundError复发5.1 个人开发环境5.2 团队开发环境六、总结关键点回顾一、报错核心认知核心是「环境一致拼写正确依赖完整」ModuleNotFoundError: No module named requests-html是requests-html使用的高频入门报错核心特征是关键拼写陷阱安装命令pip install requests-html必须用横线若写成requests_html会安装失败导入代码from requests_html import HTMLSession必须用下划线若写成requests-html会语法错误/模块找不到版本兼容核心规则requests-html 0.10.x如0.10.0主流稳定版支持Python 3.7~3.13适配新版pyppeteerrequests-html 0.9.x如0.9.0仅支持Python 3.6~3.10最后支持3.6的版本无Python 2.7支持依赖现代Python语法如f-string、类型注解完全放弃Python 2兼容依赖特性核心强制依赖自动随requests-html安装requests2.22.0、pyppeteer1.0.0JS渲染、beautifulsoup44.8.0、lxml4.6.0、pyquery1.4.0关键依赖坑点pyppeteer首次运行需自动下载Chromium约100MB国内网络易下载失败导致requests-html虽安装成功但无法正常使用无底层编译依赖lxml若已预装则无需编译安装失败主要源于依赖下载中断易混淆点报错既可能是import requests-html语法错误、import requests_html模块真缺失也可能是pyppeteer/Chromium缺失导致requests-html“假安装成功”。核心规则场景/需求操作方式核心特点通用安装推荐python -m pip install requests-html确保pip与当前Python版本匹配版本适配Python 3.7python -m pip install requests-html0.10.0匹配新版Python功能最全版本适配Python 3.6python -m pip install requests-html0.9.0兼容Python 3.6解决Chromium下载失败PYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrorspython -m pip install requests-html用淘宝源下载Chromium权限不足安装python -m pip install requests-html --user安装到用户目录避免权限报错虚拟环境修复激活虚拟环境后执行python -m pip install requests-html补装虚拟环境的requests-html验证安装python -c from requests_html import HTMLSession验证模块是否真可用requests-html版本支持Python版本核心说明0.10.x3.7 ~ 3.13主流稳定版支持新版pyppeteer0.9.x3.6 ~ 3.10最后支持3.6的版本≤0.8.x3.6 ~ 3.9淘汰版本无安全更新报错本质要么是安装/导入名拼写错误要么是requests-html未安装到当前Python环境要么是核心依赖pyppeteer/Chromium缺失要么是Python版本不兼容核心特征执行pip install requests-html提示成功但from requests_html import HTMLSession触发报错常出现在编写网页爬取代码时报错触发逻辑新手典型操作拼写错误安装用pip install requests_html下划线→ 找不到包或导入用import requests-html横线→ 语法错误环境错位用pip3 install requests-html安装绑定Python 3.10→ 用python绑定Python 2.7执行导入 → 抛出报错依赖缺失pyppeteer下载Chromium失败 → requests-html安装成功但导入时报错版本不兼容Python 3.6安装requests-html 0.10.0 → 安装失败/导入报错。1.1 典型报错输出场景1安装/导入名拼写错误最常见占比30%# 错误安装用下划线pipinstallrequests_html# 输出ERROR: Could not find a version that satisfies the requirement requests_html# 错误导入用横线python -cimport requests-html# 输出SyntaxError: invalid syntax# 正确安装但错误导入新手易混pipinstallrequests-html# 安装成功python -cimport requests-html# 仍报错# 核心报错ModuleNotFoundError: No module namedrequests-html# 本质导入名用了横线正确是下划线场景2pip与python版本错位占比20%# 用pip3安装绑定Python 3.10pip3installrequests-html# 输出Successfully installed requests-html-0.10.0 pyppeteer-1.0.2 ...# 用python绑定Python 2.7验证导入python -cfrom requests_html import HTMLSession# 核心报错ModuleNotFoundError: No module namedrequests_html# 本质pip3装到Python3python命令调用Python2环境不匹配场景3Python版本过低导致安装失败# Python 3.6环境安装requests-html 0.10.0不兼容python -m pipinstallrequests-html0.10.0# 输出ERROR: Could not find a version that satisfies the requirement requests-html0.10.0# 本质requests-html 0.10不支持Python 3.6场景4Chromium下载失败导致“假安装成功”# 安装requests-html时pyppeteer下载Chromium超时pipinstallrequests-html# 输出Successfully installed requests-html-0.10.0 ... 但包含警告# WARNING: pyppeteer requires a chromium-based browser...# 验证导入python -cfrom requests_html import HTMLSession; sessionHTMLSession()# 核心报错ModuleNotFoundError: No module namedpyppeteer# 或ChromiumDownloadError# 本质pyppeteer未完整安装/Chromium下载失败导致requests-html无法使用场景5权限不足导致安装失败# Linux/macOS无管理员权限全局安装pipinstallrequests-html# 核心错误输出ERROR: Could notinstallpackages due to an OSError:[Errno13]Permission denied:/usr/lib/python3.10/site-packages/requests_html# 运行时报错python -cfrom requests_html import HTMLSessionModuleNotFoundError: No module namedrequests_html# 本质无权限写入系统Python目录requests-html未成功安装二、报错根源拆解6大类核心诱因该问题的底层逻辑是运行代码时当前Python环境找不到requests_html模块 → 要么是安装/导入名拼写错误要么是模块未安装/安装不完整要么是环境/版本不兼容要么是核心依赖pyppeteer/Chromium缺失 → 抛出ModuleNotFoundError。核心诱因分为6类2.1 核心诱因1安装/导入名拼写错误占比30%安装时用下划线pip install requests_html正确是横线requests-html导入时用横线import requests-html语法错误或from requests-html import HTMLSession正确是下划线requests_html2.2 核心诱因2环境/版本错位占比20%pip与python版本不匹配如pip绑定Python 2、pip3装到Python 3.8但python3.10调用虚拟环境未激活requests-html装到系统Python但在虚拟环境中执行导入Conda环境与系统Python冲突Anaconda的Python覆盖系统路径导致模块无法识别2.3 核心诱因3依赖缺失/Chromium下载失败占比20%网络波动导致pyppeteer、lxml、beautifulsoup4等核心依赖未完整下载国内网络无法访问Google源导致pyppeteer下载Chromium超时/失败杀毒软件拦截Chromium下载包导致依赖安装不完整2.4 核心诱因4安装不完整/缓存损坏占比10%安装过程中手动中断CtrlC导致requests_html目录未完整创建pip缓存损坏安装包解压失败核心模块如requests_html/HTMLSession.py缺失2.5 核心诱因5权限不足占比10%Linux/macOS无全局安装权限无法写入系统Python目录Windows无管理员权限无法写入C:\PythonX\Lib\site-packages2.6 核心诱因6Python版本不兼容占比10%Python 3.6安装requests-html 0.10.x仅支持3.7Python 3.5/2.7安装任意版本requests-html完全不支持三、系统化解决步骤分场景适配解决该问题的核心逻辑是纠正拼写错误 确保pip与python版本一致 适配Python/requests-html版本 完整安装依赖含Chromium 激活对应环境 配置权限优先级拼写纠错 通用安装 依赖修复 版本适配 权限适配。3.1 前置验证5分钟快速定位根源# 1. 验证当前运行的Python版本关键匹配requests-html版本python --version# 示例输出Python 3.10.11 → 适配0.10.xPython 3.6.15 → 适配0.9.0# 2. 验证pip对应的Python版本pip --version# 输出示例pip 24.0 from .../python3.10/site-packages/pip → 匹配则正常# 3. 验证是否正确安装requests-html注意是下划线python -m pip show requests-html# 安装名是横线# 若输出“WARNING: Package(s) not found: requests-html” → 未安装# 4. 检查虚拟环境状态# Linux/macOSecho$VIRTUAL_ENV# 有输出则激活了虚拟环境# WindowsPowerShell$env:VIRTUAL_ENV# 5. 验证核心依赖是否完整python -c import requests, bs4, lxml, pyquery print(requests版本, requests.__version__) print(bs4版本, bs4.__version__) print(所有基础依赖导入成功) # 6. 验证requests-html是否真可用关键python -c from requests_html import HTMLSession session HTMLSession() resp session.get(https://httpbin.org/html) print(requests-html导入成功响应状态码, resp.status_code) 3.2 方案1核心修复——正确安装含Chromium国内源这是解决该报错的最核心方案先纠正拼写错误用python -m pip绑定当前Python版本通过淘宝源下载Chromium完整安装requests-html# 关键Windows/macOS/Linux通用安装命令 # 步骤1设置pyppeteer国内源解决Chromium下载失败# Linux/macOSexportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# Windows CMDsetPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# Windows PowerShell$env:PYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# 步骤2正确安装requests-html用横线 国内PyPI源加速python -m pipinstallrequests-html -i https://pypi.tuna.tsinghua.edu.cn/simple/# 步骤3指定版本安装根据Python版本适配# Python 3.7推荐最新版python -m pipinstallrequests-html0.10.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/# Python 3.6仅支持0.9.0python -m pipinstallrequests-html0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/# 验证安装关键导入用下划线 # 1. 模块导入验证python -c from requests_html import HTMLSession print(requests-html导入成功版本, __import__(requests_html).__version__) # 输出requests-html导入成功版本0.10.0 → 安装成功# 2. 功能验证渲染JS网页python -c from requests_html import HTMLSession # 创建会话自动加载pyppeteer/Chromium session HTMLSession() # 请求包含JS的网页 resp session.get(https://www.baidu.com) # 渲染JS首次运行会自动下载Chromium耐心等待 resp.html.render() # 提取标题验证JS渲染成功 title resp.html.xpath(//title/text())[0] print(JS渲染后网页标题, title) print(requests-html核心功能正常) # 输出JS渲染后网页标题百度一下你就知道 → 功能正常3.3 方案2拼写纠错——解决最易踩坑的安装/导入错误若报错是因拼写错误导致按以下步骤纠正错误1安装时用了下划线requests_html# 错误命令会失败pipinstallrequests_html# 正确命令用横线python -m pipinstallrequests-html -i https://pypi.tuna.tsinghua.edu.cn/simple/错误2导入时用了横线requests-html# 错误代码语法错误/模块找不到importrequests-html# 横线导致语法错误fromrequests-htmlimportHTMLSession# 横线导致模块找不到# 正确代码用下划线fromrequests_htmlimportHTMLSession# 核心导入importrequests_html# 整体导入3.4 方案3虚拟环境修复补装缺失的requests-html若虚拟环境中缺失requests-html需激活环境后重新安装# 步骤1激活虚拟环境# Linux/macOSsourcereq_html_env/bin/activate# WindowsCMDreq_html_env\Scripts\activate# WindowsPowerShell.\req_html_env\Scripts\Activate.ps1# 步骤2设置Chromium国内源 安装requests-html# Linux/macOSexportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# WindowssetPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# 3.7环境python -m pipinstallrequests-html0.10.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/# 3.6环境# python -m pip install requests-html0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/# 步骤3验证安装python -cfrom requests_html import HTMLSession; print(虚拟环境中requests-html可用)3.5 方案4权限适配——无管理员权限安装若Linux/macOS/Windows无全局安装权限用--user安装到用户目录# 步骤1设置Chromium国内源# Linux/macOSexportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# WindowssetPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# 步骤2--user安装requests-html# 3.7python -m pipinstallrequests-html0.10.0 --user -i https://pypi.tuna.tsinghua.edu.cn/simple/# 3.6# python -m pip install requests-html0.9.0 --user -i https://pypi.tuna.tsinghua.edu.cn/simple/# 步骤3配置用户目录到PATH解决命令/模块路径问题# Linux/macOS临时生效exportPATH$PATH:~/.local/bin# Linux/macOS永久生效bashechoexport PATH\$PATH:~/.local/bin~/.bashrcsource~/.bashrc# Windows手动添加%USERPROFILE%\AppData\Roaming\Python\Python310\Scripts到PATH# 步骤4验证安装python -cfrom requests_html import HTMLSession; print(无权限安装成功)3.6 方案5修复方案——重装requests-html缓存/依赖损坏若安装后仍报错清理pip缓存并重装所有依赖# 步骤1卸载现有requests-html及核心依赖python -m pip uninstall requests-html requests pyppeteer beautifulsoup4 lxml pyquery -y# 步骤2清理pip缓存pip cache purge# 步骤3设置Chromium国内源 重装# Linux/macOSexportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# WindowssetPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# 3.7python -m pipinstallrequests-html0.10.0 --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple/# 3.6# python -m pip install requests-html0.9.0 --no-cache-dir -i https://pypi.tuna.tsinghua.edu.cn/simple/# 步骤4验证安装pip show requests-html# 有Location字段则成功python -cfrom requests_html import HTMLSession; sessionHTMLSession(); print(重装成功)3.7 方案6离线安装无网络/内网环境若无法访问PyPI源手动下载所有包安装# 步骤1下载对应版本的wheel包清华源# requests-htmlhttps://pypi.tuna.tsinghua.edu.cn/simple/requests-html/# requestshttps://pypi.tuna.tsinghua.edu.cn/simple/requests/# pyppeteerhttps://pypi.tuna.tsinghua.edu.cn/simple/pyppeteer/# beautifulsoup4https://pypi.tuna.tsinghua.edu.cn/simple/beautifulsoup4/# lxmlhttps://pypi.tuna.tsinghua.edu.cn/simple/lxml/# pyqueryhttps://pypi.tuna.tsinghua.edu.cn/simple/pyquery/# 3.7requests_html-0.10.0-py3-none-any.whl requests-2.31.0-py3-none-any.whl pyppeteer-1.0.2-py3-none-any.whl beautifulsoup4-4.12.3-py3-none-any.whl lxml-4.9.4-cp310-cp310-manylinux_2_17_x86_64.whl pyquery-2.0.0-py3-none-any.whl# 步骤2按顺序安装依赖python -m pipinstallrequests-2.31.0-py3-none-any.whl --user python -m pipinstallbeautifulsoup4-4.12.3-py3-none-any.whl --user python -m pipinstalllxml-4.9.4-cp310-cp310-manylinux_2_17_x86_64.whl --user python -m pipinstallpyquery-2.0.0-py3-none-any.whl --user python -m pipinstallpyppeteer-1.0.2-py3-none-any.whl --user# 步骤3安装requests-htmlpython -m pipinstallrequests_html-0.10.0-py3-none-any.whl --user# 步骤4手动下载Chromium国内源# 下载地址https://npm.taobao.org/mirrors/chromium-browser-snapshots/# 解压后设置环境变量PYPPETEER_CHROMIUM_PATH解压路径/chrome# 步骤5验证安装python -cfrom requests_html import HTMLSession; print(离线安装成功)3.8 方案7PyCharm环境适配子场景1PyCharm中运行requests-html代码报错缺失模块打开PyCharm →File→Settings→Project: xxx→Python Interpreter点击号 → 搜索requests-html注意是横线→ 点击Install Package若Python 3.7默认装0.10.x即可若Python 3.6手动指定版本0.9.0可选若Chromium下载失败在PyCharm终端执行# Linux/macOSexportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# WindowssetPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors python -m pipinstallpyppeteer --force-reinstall编写测试代码运行无报错则完成# test_requests_html.pyfromrequests_htmlimportHTMLSessionif__name____main__:sessionHTMLSession()respsession.get(https://httpbin.org/html)print(f响应状态码{resp.status_code})print(f网页标题{resp.html.find(h1,firstTrue).text})子场景2PyCharm虚拟环境中识别不到requests-html在PyCharm中切换到项目虚拟环境 → 打开终端执行方案3的安装命令刷新PyCharm解释器缓存File→Invalidate Caches / Restart→Invalidate and Restart重新运行代码确认模块可用。四、排障技巧修复后仍提示模块找不到4.1 安装requests-html后仍报ModuleNotFoundError: No module named ‘requests_html’原因安装/导入名拼写错误pip与python版本不匹配Python 3.6装了0.10.x版本pyppeteer/Chromium下载失败导致模块“假安装”安装路径未加入sys.path。解决方案强制指定Python路径安装/运行# Linux/macOS查看Python路径whichpython# 输出/usr/bin/python3.10# 设置国内源exportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors# 重新安装/usr/bin/python3.10 -m pipinstallrequests-html# 验证导入/usr/bin/python3.10 -cfrom requests_html import HTMLSession针对版本不兼容降级# Python 3.6降级到0.9.0python -m pip uninstall requests-html -y python -m pipinstallrequests-html0.9.0手动修复pyppeteer/Chromium# 强制重装pyppeteerpython -m pipinstallpyppeteer --force-reinstall# 手动下载Chromium后指定路径exportPYPPETEER_CHROMIUM_PATH/path/to/chromium/chrome python -cfrom requests_html import HTMLSession; sessionHTMLSession()验证Python的sys.pathpython -c import sys print(Python路径列表, sys.path) # 手动添加安装路径示例 # sys.path.append(/usr/lib/python3.10/site-packages) from requests_html import HTMLSession 4.2 Linux/macOS报“Permission denied”安装失败原因无权限写入系统Python目录sudo pip绑定系统Python导致版本错位。解决方案优先用--user安装推荐exportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors python -m pipinstallrequests-html --user若必须全局安装用sudo指定Python版本sudoPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors /usr/bin/python3.10 -m pipinstallrequests-html4.3 网络问题导致无法下载requests-html/pyppeteer原因访问PyPI官方源超时国内网络无法下载Chromium。解决方案使用国内PyPI源安装python -m pipinstallrequests-html -i https://mirrors.aliyun.com/pypi/simple/配置pip永久使用国内源# Linux/macOSmkdir-p ~/.config/pipecho[global] index-url https://pypi.tuna.tsinghua.edu.cn/simple~/.config/pip/pip.conf# WindowsPowerShellmkdir$env:APPDATA\pipecho[global] index-url https://pypi.tuna.tsinghua.edu.cn/simple$env:APPDATA\pip\pip.ini手动下载Chromium绕过pyppeteer自动下载下载地址https://npm.taobao.org/mirrors/chromium-browser-snapshots/解压后设置环境变量PYPPETEER_CHROMIUM_PATH解压路径/chrome4.4 Conda环境中导入requests-html失败原因Conda环境未激活requests-html装到系统PythonConda的Python版本与requests-html不兼容Conda的pip与系统pip冲突。解决方案激活Conda环境后安装conda activate req_html_env# 设置Chromium国内源exportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors pipinstallrequests-html用Conda安装核心依赖备选conda activate req_html_env condainstall-c conda-forge requests beautifulsoup4 lxml pyquery pipinstallpyppeteer requests-html五、预防措施避免ModuleNotFoundError复发5.1 个人开发环境牢记核心规则安装命令python -m pip install requests-html横线导入代码from requests_html import HTMLSession下划线版本匹配3.7装0.10.x3.6装0.9.03.5以下升级Python必设国内源安装前先设置PYPPETEER_DOWNLOAD_HOST避免Chromium下载失败。避免混用全局/虚拟环境优先使用虚拟环境管理requests-html防止不同项目版本冲突。固定依赖版本在requirements.txt中明确指定版本避免自动升级导致兼容问题# 3.7环境 requests-html0.10.0 requests2.31.0 pyppeteer1.0.2 beautifulsoup44.12.3 lxml4.9.4 pyquery2.0.0 # 3.6环境 # requests-html0.9.0 # requests2.31.0 # pyppeteer0.2.6 # beautifulsoup44.12.3 # lxml4.9.4 # pyquery2.0.05.2 团队开发环境标准化环境配置提供统一的安装脚本包含国内源配置# install_req_html.shLinux/macOS#!/bin/bashexportPYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors python -m venv req_html_envsourcereq_html_env/bin/activate pipinstallrequests-html0.10.0 -i https://pypi.tuna.tsinghua.edu.cn/simple/echorequests-html环境安装完成CI/CD自动验证在流水线中验证安装和功能# .gitlab-ci.yml示例test-requests-html:script:-export PYPPETEER_DOWNLOAD_HOSThttps://npm.taobao.org/mirrors-python-m pip install requests-html0.10.0-python-c from requests_html import HTMLSession; sessionHTMLSession(); respsession.get(https://httpbin.org/html); assert resp.status_code 200-echo requests-html验证通过六、总结ModuleNotFoundError: No module named requests-html的核心解决思路是纠正安装/导入名拼写 确保pip与python版本一致 适配Python/requests-html版本 完整安装依赖含Chromium国内源 激活对应环境 配置权限核心方案先设置PYPPETEER_DOWNLOAD_HOST国内源再用python -m pip install requests-html横线安装导入时用requests_html下划线3.7装0.10.x3.6装0.9.0无权限加--user关键避坑避免安装用下划线、导入用横线避免Python 3.6装0.10.x避免未设置国内源导致Chromium下载失败适配技巧报错90%源于拼写错误/环境错位/Chromium下载失败国内源可解决90%的依赖下载问题清理缓存可修复安装不完整。关键点回顾requests-html的安装名是横线、导入名是下划线这是新手最易踩的拼写坑修复的核心技巧是用python -m pip安装绑定当前Python、设置PYPPETEER_DOWNLOAD_HOST国内源、验证导入时用下划线requests-html版本与Python强绑定0.10.x→3.70.9.0→3.6版本选错直接导致安装/导入失败。【专栏地址】更多 Python 网页爬取、requests-html使用高频问题解决方案欢迎订阅我的 CSDN 专栏全栈BUG解决方案