Langchain-Chatchat
Langchain-Chatchat copied to clipboard
[FEATURE] 启动时发生错误
python3 startup.py -a
Traceback (most recent call last):
File "/Users/hbz/git/Langchain-Chatchat/startup.py", line 35, in
is:issue is:open No module named 'fastapi'
嗨,@huangbz2007!很高兴再次看到你在这里提出问题。希望你一切都好!
您遇到的 "ModuleNotFoundError: No module named 'fastapi'" 错误是因为您正在运行脚本的 Python 环境中没有安装 FastAPI 库。FastAPI 是一个用于构建 API 的现代、快速(高性能)的 Python 3.6+ web 框架,基于标准的 Python 类型提示。
Langchain-Chatchat 仓库的 startup.py 脚本在多处导入了 FastAPI,例如:
from server.utils import (fschat_controller_address, fschat_model_worker_address,
fschat_openai_api_address, get_httpx_client, get_model_worker_config,
MakeFastAPIOffline, FastAPI, llm_device, embedding_device)
然后使用它来创建 FastAPI 应用:
def create_controller_app(
dispatch_method: str,
log_level: str = "INFO",
) -> FastAPI:
...
return app
要解决此错误,您需要在您的 Python 环境中安装 FastAPI。您可以通过运行以下命令来实现:
pip install fastapi
请确保您在尝试运行 startup.py 脚本的同一 Python 环境中运行此命令。
关于类似问题,我在 Langchain-Chatchat 仓库中找到了一些相关的问题。例如,这个问题中的用户遇到了类似的错误,并通过降级 llama-index 库到 0.9.35 版本来解决问题。您可以参考这个解决方案,看看是否能解决您的问题。
如果问题仍然存在,您可能需要检查您的环境配置,确保所有的依赖项都已正确安装。
Sources
- [BUG] 简洁阐述问题 / 使用命令 python startup.py -a启动时出错
- [BUG] Langchain-chatchat 一键启动项目 python startup.py -a 报错
- 系统找不到指定的文件
- [BUG] 简洁阐述问题 / Concise description of the issue
- startup.py
- server/api.py
About Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain/chat_models/init.py:31: LangChainDeprecationWarning: Importing chat models from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
from langchain_community.chat_models import ChatOpenAI.
To install langchain-community run pip install -U langchain-community.
warnings.warn(
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain/llms/init.py:548: LangChainDeprecationWarning: Importing LLMs from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
from langchain_community.llms import OpenAI.
To install langchain-community run pip install -U langchain-community.
warnings.warn(
/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pydantic/_internal/_config.py:322: UserWarning: Valid config keys have changed in V2:
- 'schema_extra' has been renamed to 'json_schema_extra' warnings.warn(message, UserWarning) /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/langchain/document_loaders/init.py:36: LangChainDeprecationWarning: Importing document loaders from langchain is deprecated. Importing from langchain will no longer be supported as of langchain==0.2.0. Please import from langchain-community instead:
from langchain_community.document_loaders import JSONLoader.
To install langchain-community run pip install -U langchain-community.
warnings.warn(
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so, 0x0002): tried: '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so' (no such file), '/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/_cffi_backend.cpython-312-darwin.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
thread 'RUST_BACKTRACE=1 environment variable to display a backtrace
Traceback (most recent call last):
File "/Users/hbz/git/Langchain-Chatchat/startup.py", line 38, in
It seems like this issue requires a deeper look, @imClumsyPanda could you please lend your expertise?
@imClumsyPanda 麻烦看下哦
目前3.12还没有进行测试,建议按照项目readme和wiki中的版本要求及依赖包安装完成后再启动项目