Langchain-Chatchat icon indicating copy to clipboard operation
Langchain-Chatchat copied to clipboard

[BUG] 执行python startup.py -a报错,请大神帮忙解决下

Open haitongwan opened this issue 1 year ago • 3 comments

==============================Langchain-Chatchat Configuration============================== 操作系统:Linux-5.4.0-42-generic-x86_64-with-glibc2.31. python版本:3.11.7 (main, Dec 15 2023, 18:12:31) [GCC 11.2.0] 项目版本:v0.2.10 langchain版本:0.0.354. fastchat版本:0.2.35

当前使用的分词器:ChineseRecursiveTextSplitter 当前启动的LLM模型:['chatglm3-6b'] @ cuda {'device': 'cuda', 'host': '0.0.0.0', 'infer_turbo': False, 'model_path': '/home/data/llm/chatglm3-6b', 'model_path_exists': True, 'port': 20002} 当前Embbedings模型: bge-large-zh @ cuda ==============================Langchain-Chatchat Configuration==============================

2024-02-21 15:15:54,059 - startup.py[line:655] - INFO: \u6b63\u5728\u542f\u52a8\u670d\u52a1\uff1a 2024-02-21 15:15:54,059 - startup.py[line:656] - INFO: \u5982\u9700\u67e5\u770b llm_api \u65e5\u5fd7\uff0c\u8bf7\u524d\u5f80 /home/data/llm/Langchain-Chatchat/logs /usr/local/anaconda3/envs/llm_langchain_chat/lib/python3.11/site-packages/langchain_core/_api/deprecation.py:117: LangChainDeprecationWarning: \u6a21\u578b\u542f\u52a8\u529f\u80fd\u5c06\u4e8e Langchain-Chatchat 0.3.x\u91cd\u5199,\u652f\u6301\u66f4\u591a\u6a21\u5f0f\u548c\u52a0\u901f\u542f\u52a8\uff0c0.2.x\u4e2d\u76f8\u5173\u529f\u80fd\u5c06\u5e9f\u5f03 warn_deprecated( 2024-02-21 15:16:00 | ERROR | stderr | INFO: Started server process [327818] 2024-02-21 15:16:00 | ERROR | stderr | INFO: Waiting for application startup. 2024-02-21 15:16:00 | ERROR | stderr | INFO: Application startup complete. 2024-02-21 15:16:00 | ERROR | stderr | INFO: Uvicorn running on http://0.0.0.0:20000 (Press CTRL+C to quit) 2024-02-21 15:16:01 | INFO | model_worker | Loading the model ['chatglm3-6b'] on worker aa9a324b ... Loading checkpoint shards: 0%| | 0/7 [00:00<?, ?it/s] Loading checkpoint shards: 14%|#############################7 | 1/7 [00:00<00:02, 2.49it/s] Loading checkpoint shards: 29%|###########################################################4 | 2/7 [00:00<00:01, 2.71it/s] Loading checkpoint shards: 43%|#########################################################################################1 | 3/7 [00:01<00:01, 2.65it/s] Loading checkpoint shards: 57%|######################################################################################################################8 | 4/7 [00:01<00:01, 2.65it/s] Loading checkpoint shards: 71%|####################################################################################################################################################5 | 5/7 [00:01<00:00, 2.60it/s] Loading checkpoint shards: 86%|##################################################################################################################################################################################2 | 6/7 [00:02<00:00, 2.65it/s] Loading checkpoint shards: 100%|################################################################################################################################################################################################################| 7/7 [00:02<00:00, 3.01it/s] Loading checkpoint shards: 100%|################################################################################################################################################################################################################| 7/7 [00:02<00:00, 2.78it/s] 2024-02-21 15:16:04 | ERROR | stderr | 2024-02-21 15:16:06 | INFO | model_worker | Register to controller INFO: Started server process [327977] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://0.0.0.0:7861 (Press CTRL+C to quit)

==============================Langchain-Chatchat Configuration============================== 操作系统:Linux-5.4.0-42-generic-x86_64-with-glibc2.31. python版本:3.11.7 (main, Dec 15 2023, 18:12:31) [GCC 11.2.0] 项目版本:v0.2.10 langchain版本:0.0.354. fastchat版本:0.2.35

当前使用的分词器:ChineseRecursiveTextSplitter 当前启动的LLM模型:['chatglm3-6b'] @ cuda {'device': 'cuda', 'host': '0.0.0.0', 'infer_turbo': False, 'model_path': '/home/data/llm/chatglm3-6b', 'model_path_exists': True, 'port': 20002} 当前Embbedings模型: bge-large-zh @ cuda

2024-02-21 15:16:16,667 - startup.py[line:850] - ERROR: 'latin-1' codec can't encode characters in position 0-7: ordinal not in range(256) 2024-02-21 15:16:16,667 - startup.py[line:851] - WARNING: Caught KeyboardInterrupt! Setting stop event... 2024-02-21 15:16:16,667 - startup.py[line:855] - WARNING: Sending SIGKILL to {} 2024-02-21 15:16:16,667 - startup.py[line:855] - WARNING: Sending SIGKILL to {'chatglm3-6b': <Process name='model_worker - chatglm3-6b (327819)' pid=327819 parent=327609 started daemon>} 2024-02-21 15:16:16,668 - startup.py[line:855] - WARNING: Sending SIGKILL to <Process name='controller (327745)' pid=327745 parent=327609 started daemon> 2024-02-21 15:16:16,669 - startup.py[line:855] - WARNING: Sending SIGKILL to <Process name='openai_api (327818)' pid=327818 parent=327609 started daemon> 2024-02-21 15:16:16,669 - startup.py[line:855] - WARNING: Sending SIGKILL to <Process name='API Server (327977)' pid=327977 parent=327609 started daemon> 2024-02-21 15:16:16,670 - startup.py[line:855] - WARNING: Sending SIGKILL to <Process name='WEBUI Server (328080)' pid=328080 parent=327609 started daemon> 2024-02-21 15:16:16,670 - startup.py[line:866] - INFO: Process status: {} 2024-02-21 15:16:16,670 - startup.py[line:866] - INFO: Process status: {'chatglm3-6b': <Process name='model_worker - chatglm3-6b (327819)' pid=327819 parent=327609 started daemon>} 2024-02-21 15:16:16,671 - startup.py[line:866] - INFO: Process status: <Process name='controller (327745)' pid=327745 parent=327609 started daemon> 2024-02-21 15:16:16,671 - startup.py[line:866] - INFO: Process status: <Process name='openai_api (327818)' pid=327818 parent=327609 started daemon> 2024-02-21 15:16:16,671 - startup.py[line:866] - INFO: Process status: <Process name='API Server (327977)' pid=327977 parent=327609 started daemon> 2024-02-21 15:16:16,671 - startup.py[line:866] - INFO: Process status: <Process name='WEBUI Server (328080)' pid=328080 parent=327609 started daemon>

Collecting usage statistics. To deactivate, set browser.gatherUsageStats to False.

You can now view your Streamlit app in your browser.

URL: http://0.0.0.0:8501

/usr/local/anaconda3/envs/llm_langchain_chat/lib/python3.11/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d ' (llm_langchain_chat) root@Server-e2b50cf1-5234-44a8-bbea-d6fb7a155d7a:/home/data/llm/Langchain-Chatchat# 2024-02-21 15:16:48,053 - utils.py[line:95] - ERROR: ConnectError: error when post /llm_model/list_running_models: [Errno 111] Connection refused 2024-02-21 15:16:48,054 - utils.py[line:95] - ERROR: ConnectError: error when post /llm_model/list_running_models: [Errno 111] Connection refused 2024-02-21 15:16:48,054 - utils.py[line:95] - ERROR: ConnectError: error when post /llm_model/list_running_models: [Errno 111] Connection refused 2024-02-21 15:16:48,157 - utils.py[line:95] - ERROR: ConnectError: error when post /llm_model/list_running_models: [Errno 111] Connection refused 2024-02-21 15:16:48,158 - utils.py[line:95] - ERROR: ConnectError: error when post /llm_model/list_running_models: [Errno 111] Connection refused 2024-02-21 15:16:48,158 - utils.py[line:95] - ERROR: ConnectError: error when post /llm_model/list_running_models: [Errno 111] Connection refused 2024-02-21 15:16:48.158 Uncaught app exception Traceback (most recent call last): File "/usr/local/anaconda3/envs/llm_langchain_chat/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 535, in _run_script exec(code, module.dict) File "/home/data/llm/Langchain-Chatchat/webui.py", line 64, in pages[selected_page]["func"](api=api, is_lite=is_lite) File "/home/data/llm/Langchain-Chatchat/webui_pages/dialogue/dialogue.py", line 163, in dialogue_page running_models = list(api.list_running_models()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not iterable

haitongwan avatar Feb 21 '24 07:02 haitongwan

🤖

嘿,@haitongwan,又见面了!希望你近期一切都好。

根据您提供的错误日志,问题似乎出在startup.py脚本的第850行,错误信息为'latin-1' codec can't encode characters in position 0-7: ordinal not in range(256)。这个错误通常是由于尝试使用不支持某些字符的编码(在这种情况下是'latin-1')来编码这些字符时引发的。

在Langchain-Chatchat的问题跟踪中,我找到了一些类似的已解决问题,可能对您有所帮助:

  1. [BUG] Langchain-chatchat 一键启动项目 python startup.py -a 报错
  2. 执行python startup.py -a 报错
  3. [BUG] 简洁阐述问题 / Concise description of the issue

在这些问题中,有一些解决方案可能对您有所帮助。例如,确保所有文件(尤其是需要初始化的知识库)都是UTF-8格式的,因为'latin-1'编码可能无法处理某些UTF-8字符。此外,如果只有一个GPU可用,代码应设置为使用设备0,以防止在尝试使用不存在的GPU设备时出现错误。

然而,这些解决方案可能并不完全适用于您的情况,因为您的错误日志中的错误信息可能与这些问题中的错误信息不完全相同。如果这些解决方案不能解决您的问题,或者您需要更多的帮助,您可以提供更多的信息,例如错误发生的具体情况,以及您在运行startup.py脚本时使用的具体命令和参数。这将有助于我们更好地理解和解决您的问题。

Sources

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.

dosubot[bot] avatar Feb 21 '24 07:02 dosubot[bot]

🤖

嘿,@haitongwan,又见面了!希望你近期一切都好。

根据您提供的错误日志,问题似乎出在startup.py脚本的第850行,错误信息为'latin-1' codec can't encode characters in position 0-7: ordinal not in range(256)。这个错误通常是由于尝试使用不支持某些字符的编码(在这种情况下是'latin-1')来编码这些字符时引发的。

在Langchain-Chatchat的问题跟踪中,我找到了一些类似的已解决问题,可能对您有所帮助:

  1. [BUG] Langchain-chatchat 一键启动项目 python startup.py -a 报错
  2. 执行python startup.py -a 报错
  3. [BUG] 简洁阐述问题 / Concise description of the issue

在这些问题中,有一些解决方案可能对您有所帮助。例如,确保所有文件(尤其是需要初始化的知识库)都是UTF-8格式的,因为'latin-1'编码可能无法处理某些UTF-8字符。此外,如果只有一个GPU可用,代码应设置为使用设备0,以防止在尝试使用不存在的GPU设备时出现错误。

然而,这些解决方案可能并不完全适用于您的情况,因为您的错误日志中的错误信息可能与这些问题中的错误信息不完全相同。如果这些解决方案不能解决您的问题,或者您需要更多的帮助,您可以提供更多的信息,例如错误发生的具体情况,以及您在运行startup.py脚本时使用的具体命令和参数。这将有助于我们更好地理解和解决您的问题。

Sources

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.

程序中很多地方都有'latin-1' codec can't encode characters in position 0-7: ordinal not in range(256)这个错误,如何统一进行设置或者修改

haitongwan avatar Feb 21 '24 07:02 haitongwan

🤖

Based on the error message you're encountering, it seems like the issue is related to encoding. The error 'latin-1' codec can't encode characters in position 0-7: ordinal not in range(256) typically occurs when you're trying to encode a string that contains characters not supported by the 'latin-1' encoding.

In the context of Langchain-Chatchat, the files involved in the knowledge base initialization are in JSON Lines (jsonl) format. This format is typically encoded in UTF-8, which supports a much wider range of characters than 'latin-1'.

One of the similar issues in the Langchain-Chatchat repository suggests that ensuring all files, especially the knowledge base that needs to be initialized, are in UTF-8 format could potentially resolve the UnicodeEncodeError. You can check the encoding of your files using a text editor or a tool like file -i filename.

If the files are not in UTF-8 format, you can convert them using a tool like iconv or a text editor that allows you to save files in a different encoding. Here's an example of how to use iconv to convert a file to UTF-8:

iconv -f latin1 -t utf8 inputfile -o outputfile

If the files are already in UTF-8 format, the issue might be with the way the files are being read in the startup.py script. Python's built-in open function uses the platform's default encoding if no encoding is specified. On many Linux systems, this default is 'utf-8', but it can be different on other systems or if the default has been changed. You can specify the encoding when opening a file like this:

with open('filename', 'r', encoding='utf-8') as f:
    ...

If the error persists after checking and correcting the file encodings, it would be helpful to know more about the specific context in which the error occurs. Could you provide the part of the startup.py script around line 850 where the error occurs, or any other information about what the script is doing when the error occurs?

For more information, you can refer to these solved issues:

I hope this helps! If you have any more questions, feel free to ask.

Sources

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.

dosubot[bot] avatar Feb 21 '24 07:02 dosubot[bot]

这个是你文件编码的问题吧,使用utf8编码的文件

zRzRzRzRzRzRzR avatar Feb 22 '24 14:02 zRzRzRzRzRzRzR