binary-husky/gpt_academic · error · ModuleNotFoundError
使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements.txt` 指令
Error message
使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements.txt` 指令安装内置Gradio及其他依赖, 详情信息见requirements.txt.
What it means
main() hard-checks the installed Gradio version against exactly '3.32.15' and raises ModuleNotFoundError otherwise. This project pins its UI to that specific Gradio 3.x line because its interface code depends on 3.x APIs; both older and all 4.x/5.x releases trip the check. The exception type is misleading — the module exists, only the version differs.
Source
Thrown at main.py:38
def encode_plugin_info(k, plugin)->str:
import copy
from themes.theme import to_cookie_str
plugin_ = copy.copy(plugin)
plugin_.pop("Function", None)
plugin_.pop("Class", None)
plugin_.pop("Button", None)
plugin_["Info"] = plugin.get("Info", k)
if plugin.get("AdvancedArgs", False):
plugin_["Label"] = f"插件[{k}]的高级参数说明:" + plugin.get("ArgsReminder", f"没有提供高级参数功能说明")
else:
plugin_["Label"] = f"插件[{k}]不需要高级参数。"
return to_cookie_str(plugin_)
def main():
import gradio as gr
if gr.__version__ not in ['3.32.15']:
raise ModuleNotFoundError("使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements.txt` 指令安装内置Gradio及其他依赖, 详情信息见requirements.txt.")
# 一些基础工具
from toolbox import format_io, find_free_port, on_file_uploaded, on_report_generated, get_conf, ArgsGeneralWrapper, DummyWith
# 对话、日志记录
enable_log(get_conf("PATH_LOGGING"))
# 对话句柄
from request_llms.bridge_all import predict
# 读取配置
proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION = get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION')
CHATBOT_HEIGHT, LAYOUT, AVAIL_LLM_MODELS, AUTO_CLEAR_TXT = get_conf('CHATBOT_HEIGHT', 'LAYOUT', 'AVAIL_LLM_MODELS', 'AUTO_CLEAR_TXT')
ENABLE_AUDIO, AUTO_CLEAR_TXT, AVAIL_FONTS, AVAIL_THEMES, THEME, ADD_WAIFU = get_conf('ENABLE_AUDIO', 'AUTO_CLEAR_TXT', 'AVAIL_FONTS', 'AVAIL_THEMES', 'THEME', 'ADD_WAIFU')
NUM_CUSTOM_BASIC_BTN, SSL_KEYFILE, SSL_CERTFILE = get_conf('NUM_CUSTOM_BASIC_BTN', 'SSL_KEYFILE', 'SSL_CERTFILE')
DARK_MODE, INIT_SYS_PROMPT, ADD_WAIFU, TTS_TYPE = get_conf('DARK_MODE', 'INIT_SYS_PROMPT', 'ADD_WAIFU', 'TTS_TYPE')
if LLM_MODEL not in AVAIL_LLM_MODELS: AVAIL_LLM_MODELS += [LLM_MODEL]
View on GitHub (pinned to d6bde0fa54)
Solutions
- Install the pinned stack: pip install -r requirements.txt (it pins gradio==3.32.15).
- Or explicitly: pip install gradio==3.32.15.
- Use a dedicated virtualenv/conda env for this project so other tools cannot bump gradio.
- Do not try to run with gradio 4.x without porting the UI code — the APIs differ substantially.
Example fix
# before pip install gradio # installs 5.x -> check fails # after python -m pip install -r requirements.txt # or: pip install gradio==3.32.15
Defensive patterns
Strategy: validation
Validate before calling
import gradio
def gradio_version_ok() -> bool:
return gradio.__version__ == '3.32.15'
if not gradio_version_ok():
raise SystemExit('run: pip install -r requirements.txt (pins gradio==3.32.15)') Try / catch
try:
main()
except ModuleNotFoundError as e:
if 'Gradio' in str(e):
print('Fix: pip install -r requirements.txt'); raise SystemExit(1)
raise Prevention
- Install deps strictly from requirements.txt in a dedicated virtualenv.
- Pin gradio==3.32.15 in any extra dependency files you add.
- Avoid `pip install -U` in this environment — one upgrade silently breaks the pinned UI.
When it happens
Trigger: Launching main.py with any gradio != 3.32.15 installed — typically after `pip install gradio` (latest 4.x/5.x), after upgrading dependencies for another tool, or in a fresh env that installed requirements.txt incompletely.
Common situations: Fresh clones that skipped `pip install -r requirements.txt`; shared environments where another project forced a newer gradio; `pip install -U` upgrades breaking the pin; CI images caching a newer gradio wheel.
Related errors
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/ece2f9decde51f0b.
Report an issue: GitHub.