{"record":{"id":"ece2f9decde51f0b","repo":"binary-husky/gpt_academic","slug":"gradio-pip-install-r-requiremen","errorCode":null,"errorMessage":"使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements.txt` 指令安装内置Gradio及其他依赖, 详情信息见requirements.txt.","messagePattern":"使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements\\.txt` 指令安装内置Gradio及其他依赖, 详情信息见requirements\\.txt\\.","errorType":"exception","errorClass":"ModuleNotFoundError","httpStatus":null,"severity":"error","filePath":"main.py","lineNumber":38,"sourceCode":"\ndef encode_plugin_info(k, plugin)->str:\n    import copy\n    from themes.theme import to_cookie_str\n    plugin_ = copy.copy(plugin)\n    plugin_.pop(\"Function\", None)\n    plugin_.pop(\"Class\", None)\n    plugin_.pop(\"Button\", None)\n    plugin_[\"Info\"] = plugin.get(\"Info\", k)\n    if plugin.get(\"AdvancedArgs\", False):\n        plugin_[\"Label\"] = f\"插件[{k}]的高级参数说明：\" + plugin.get(\"ArgsReminder\", f\"没有提供高级参数功能说明\")\n    else:\n        plugin_[\"Label\"] = f\"插件[{k}]不需要高级参数。\"\n    return to_cookie_str(plugin_)\n\ndef main():\n    import gradio as gr\n    if gr.__version__ not in ['3.32.15']:\n        raise ModuleNotFoundError(\"使用项目内置Gradio获取最优体验! 请运行 `pip install -r requirements.txt` 指令安装内置Gradio及其他依赖, 详情信息见requirements.txt.\")\n\n    # 一些基础工具\n    from toolbox import format_io, find_free_port, on_file_uploaded, on_report_generated, get_conf, ArgsGeneralWrapper, DummyWith\n\n    # 对话、日志记录\n    enable_log(get_conf(\"PATH_LOGGING\"))\n\n    # 对话句柄\n    from request_llms.bridge_all import predict\n\n    # 读取配置\n    proxies, WEB_PORT, LLM_MODEL, CONCURRENT_COUNT, AUTHENTICATION = get_conf('proxies', 'WEB_PORT', 'LLM_MODEL', 'CONCURRENT_COUNT', 'AUTHENTICATION')\n    CHATBOT_HEIGHT, LAYOUT, AVAIL_LLM_MODELS, AUTO_CLEAR_TXT = get_conf('CHATBOT_HEIGHT', 'LAYOUT', 'AVAIL_LLM_MODELS', 'AUTO_CLEAR_TXT')\n    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')\n    NUM_CUSTOM_BASIC_BTN, SSL_KEYFILE, SSL_CERTFILE = get_conf('NUM_CUSTOM_BASIC_BTN', 'SSL_KEYFILE', 'SSL_CERTFILE')\n    DARK_MODE, INIT_SYS_PROMPT, ADD_WAIFU, TTS_TYPE = get_conf('DARK_MODE', 'INIT_SYS_PROMPT', 'ADD_WAIFU', 'TTS_TYPE')\n    if LLM_MODEL not in AVAIL_LLM_MODELS: AVAIL_LLM_MODELS += [LLM_MODEL]\n","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/main.py#L20-L56","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\npip install gradio   # installs 5.x -> check fails\n\n# after\npython -m pip install -r requirements.txt   # or: pip install gradio==3.32.15","handlingStrategy":"validation","validationCode":"import gradio\n\ndef gradio_version_ok() -> bool:\n    return gradio.__version__ == '3.32.15'\n\nif not gradio_version_ok():\n    raise SystemExit('run: pip install -r requirements.txt (pins gradio==3.32.15)')","typeGuard":null,"tryCatchPattern":"try:\n    main()\nexcept ModuleNotFoundError as e:\n    if 'Gradio' in str(e):\n        print('Fix: pip install -r requirements.txt'); raise SystemExit(1)\n    raise","preventionTips":["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."],"tags":["gradio","version-pin","dependency","ui","python"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}