zhayujie / chatgpt-on-wechat

基于大模型搭建的聊天机器人,同时支持 微信公众号、企业微信应用、飞书、钉钉 等接入,可选择GPT3.5/GPT-4o/GPT-o1/ Claude/文心一言/讯飞星火/通义千问/ Gemini/GLM-4/Claude/Kimi/LinkAI,能处理文本、语音和图片,访问操作系统和互联网,支持基于自有知识库进行定制企业智能客服。
https://docs.link-ai.tech/cow
MIT License
29.84k stars 7.88k forks source link

运行 python3 app.py 报错: module 'types' has no attribute 'UnionType' #2176

Closed base0225 closed 1 month ago

base0225 commented 1 month ago

前置确认

⚠️ 搜索issues中是否已存在类似问题

操作系统类型?

MacOS

运行的python版本是?

python 3.10

使用的chatgpt-on-wechat版本是?

Latest Release

运行的channel类型是?

terminal

复现步骤 🕹

先把代码download 下来,执行pip3 install -r requirements.txt pip3 install -r requirements-optional.txt。做后跑 python3 app.py 报错:ia.zhu@SHPLMDBZHU chatgpt-on-wechat % python3.10 app.py [INFO][2024-07-24 09:45:23][config.py:295] - [INIT] load config: {'channel_type': 'wx', 'model': 'gpt-3.5-turbo', 'open_ai_api_key': 'sk-4G9', 'claude_api_key': 'YOUKEY', 'text_to_image': 'dall-e-2', 'voice_to_text': 'openai', 'text_to_voice': 'openai', 'proxy': '', 'hot_reload': False, 'single_chat_prefix': ['bot', '@bot'], 'single_chat_reply_prefix': '[bot] ', 'group_chat_prefix': ['@bot'], 'group_name_white_list': ['ChatGPT测试群', 'ChatGPT测试群2'], 'image_create_prefix': ['画'], 'speech_recognition': True, 'group_speech_recognition': False, 'voice_reply_voice': False, 'conversation_max_tokens': 2500, 'expires_in_seconds': 3600, 'character_desc': '你是基于大语言模型的AI智能助手,旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。', 'temperature': 0.7, 'subscribe_msg': '感谢您的关注!\n这里是AI智能助手,可以自由对话。\n支持语音对话。\n支持图片输入。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持tool、角色扮演和文字冒险等丰富的插件。\n输入{trigger_prefix}#help 查看详细指令。', 'use_linkai': False, 'linkai_api_key': '**', 'linkai_app_code': ''} [INFO][2024-07-24 09:45:23][config.py:219] - [Config] User datas loaded. /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning) [INFO][2024-07-24 09:45:23][plugin_manager.py:50] - Loading plugins config... [INFO][2024-07-24 09:45:23][plugin_manager.py:88] - Scaning plugins ... [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Role_v1.0 registered, path=./plugins/role [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin linkai_v0.1.0 registered, path=./plugins/linkai [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Dungeon_v1.0 registered, path=./plugins/dungeon [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin BDunit_v0.1 registered, path=./plugins/bdunit [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Finish_v1.0 registered, path=./plugins/finish [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Godcmd_v1.0 registered, path=./plugins/godcmd [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Hello_v0.1 registered, path=./plugins/hello [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Banwords_v1.0 registered, path=./plugins/banwords [INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Keyword_v0.1 registered, path=./plugins/keyword chatgpt-tool-hub version: 0.5.0 [WARNING][2024-07-24 09:45:23][plugin_manager.py:113] - Failed to import plugin tool: module 'types' has no attribute 'UnionType' [INFO][2024-07-24 09:45:23][godcmd.py:194] - [Godcmd] 因未设置口令,本次的临时口令为0651。 [INFO][2024-07-24 09:45:23][godcmd.py:210] - [Godcmd] inited [INFO][2024-07-24 09:45:23][keyword.py:40] - [keyword] {} [INFO][2024-07-24 09:45:23][keyword.py:42] - [keyword] inited. [INFO][2024-07-24 09:45:23][linkai.py:35] - [LinkAI] inited, config={'group_app_map': {'测试群名1': 'default', '测试群名2': 'Kv2fXJcH'}, 'midjourney': {'enabled': False, 'auto_translate': True, 'img_proxy': True, 'max_tasks': 3, 'max_tasks_per_user': 1, 'use_image_create_prefix': True}, 'summary': {'enabled': False, 'group_enabled': True, 'max_file_size': 5000, 'type': ['FILE', 'SHARING']}} [INFO][2024-07-24 09:45:23][role.py:69] - [Role] inited [INFO][2024-07-24 09:45:23][dungeon.py:56] - [Dungeon] inited [INFO][2024-07-24 09:45:23][hello.py:38] - [Hello] inited [INFO][2024-07-24 09:45:23][finish.py:23] - [Finish] inited Ready to login. Getting uuid of QR code. Downloading QR code. [ERROR][2024-07-24 09:45:24][wechat_channel.py:135] - module 'types' has no attribute 'UnionType' Traceback (most recent call last): File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 121, in startup itchat.auto_login( File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/lib/itchat/components/register.py", line 38, in auto_login self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback, File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/lib/itchat/components/login.py", line 56, in login qrStorage = self.get_QR(enableCmdQR=enableCmdQR, File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/lib/itchat/components/login.py", line 132, in get_QR qrCallback(uuid=uuid, status='0', qrcode=qrStorage.getvalue()) File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 86, in qrCallback import qrcode File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/qrcode/init.py", line 1, in from qrcode.main import QRCode File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/qrcode/main.py", line 18, in from qrcode.image.base import BaseImage File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/qrcode/image/base.py", line 10, in DrawerAliases = Dict[str, Tuple[Type[QRModuleDrawer], Dict[str, Any]]] File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 287, in inner return cached(args, kwds) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 978, in getitem return self.copy_with(params) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 981, in copy_with return _GenericAlias(self.origin, params, File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 874, in init self.parameters = _collect_type_vars(params) File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/typing_extensions.py", line 198, in _collect_type_vars if _should_collect_from_parameters(t): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/typing_extensions.py", line 172, in _should_collect_from_parameters t, (typing._GenericAlias, _types.GenericAlias, _types.UnionType) AttributeError: module 'types' has no attribute 'UnionType'

问题描述 😯

1741721785760_ pic

终端日志 📒

@SHPLMDBZHU chatgpt-on-wechat % python3.10 app.py
[INFO][2024-07-24 09:45:23][config.py:295] - [INIT] load config: {'channel_type': 'wx', 'model': 'gpt-3.5-turbo', 'open_ai_api_key': 'sk-*****4G9', 'claude_api_key': 'YOU*****KEY', 'text_to_image': 'dall-e-2', 'voice_to_text': 'openai', 'text_to_voice': 'openai', 'proxy': '', 'hot_reload': False, 'single_chat_prefix': ['bot', '@bot'], 'single_chat_reply_prefix': '[bot] ', 'group_chat_prefix': ['@bot'], 'group_name_white_list': ['ChatGPT测试群', 'ChatGPT测试群2'], 'image_create_prefix': ['画'], 'speech_recognition': True, 'group_speech_recognition': False, 'voice_reply_voice': False, 'conversation_max_tokens': 2500, 'expires_in_seconds': 3600, 'character_desc': '你是基于大语言模型的AI智能助手,旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。', 'temperature': 0.7, 'subscribe_msg': '感谢您的关注!\n这里是AI智能助手,可以自由对话。\n支持语音对话。\n支持图片输入。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持tool、角色扮演和文字冒险等丰富的插件。\n输入{trigger_prefix}#help 查看详细指令。', 'use_linkai': False, 'linkai_api_key': '*****', 'linkai_app_code': ''}
[INFO][2024-07-24 09:45:23][config.py:219] - [Config] User datas loaded.
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/pydub/utils.py:170: RuntimeWarning: Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work
  warn("Couldn't find ffmpeg or avconv - defaulting to ffmpeg, but may not work", RuntimeWarning)
[INFO][2024-07-24 09:45:23][plugin_manager.py:50] - Loading plugins config...
[INFO][2024-07-24 09:45:23][plugin_manager.py:88] - Scaning plugins ...
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Role_v1.0 registered, path=./plugins/role
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin linkai_v0.1.0 registered, path=./plugins/linkai
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Dungeon_v1.0 registered, path=./plugins/dungeon
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin BDunit_v0.1 registered, path=./plugins/bdunit
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Finish_v1.0 registered, path=./plugins/finish
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Godcmd_v1.0 registered, path=./plugins/godcmd
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Hello_v0.1 registered, path=./plugins/hello
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Banwords_v1.0 registered, path=./plugins/banwords
[INFO][2024-07-24 09:45:23][plugin_manager.py:41] - Plugin Keyword_v0.1 registered, path=./plugins/keyword
chatgpt-tool-hub version: 0.5.0
[WARNING][2024-07-24 09:45:23][plugin_manager.py:113] - Failed to import plugin tool: module 'types' has no attribute 'UnionType'
[INFO][2024-07-24 09:45:23][godcmd.py:194] - [Godcmd] 因未设置口令,本次的临时口令为0651。
[INFO][2024-07-24 09:45:23][godcmd.py:210] - [Godcmd] inited
[INFO][2024-07-24 09:45:23][keyword.py:40] - [keyword] {}
[INFO][2024-07-24 09:45:23][keyword.py:42] - [keyword] inited.
[INFO][2024-07-24 09:45:23][linkai.py:35] - [LinkAI] inited, config={'group_app_map': {'测试群名1': 'default', '测试群名2': 'Kv2fXJcH'}, 'midjourney': {'enabled': False, 'auto_translate': True, 'img_proxy': True, 'max_tasks': 3, 'max_tasks_per_user': 1, 'use_image_create_prefix': True}, 'summary': {'enabled': False, 'group_enabled': True, 'max_file_size': 5000, 'type': ['FILE', 'SHARING']}}
[INFO][2024-07-24 09:45:23][role.py:69] - [Role] inited
[INFO][2024-07-24 09:45:23][dungeon.py:56] - [Dungeon] inited
[INFO][2024-07-24 09:45:23][hello.py:38] - [Hello] inited
[INFO][2024-07-24 09:45:23][finish.py:23] - [Finish] inited
Ready to login.
Getting uuid of QR code.
Downloading QR code.
[ERROR][2024-07-24 09:45:24][wechat_channel.py:135] - module 'types' has no attribute 'UnionType'
Traceback (most recent call last):
  File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 121, in startup
    itchat.auto_login(
  File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/lib/itchat/components/register.py", line 38, in auto_login
    self.login(enableCmdQR=enableCmdQR, picDir=picDir, qrCallback=qrCallback,
  File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/lib/itchat/components/login.py", line 56, in login
    qrStorage = self.get_QR(enableCmdQR=enableCmdQR,
  File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/lib/itchat/components/login.py", line 132, in get_QR
    qrCallback(uuid=uuid, status='0', qrcode=qrStorage.getvalue())
  File "/Users/jia.zhu/Desktop/chatgpt-on-wechat/channel/wechat/wechat_channel.py", line 86, in qrCallback
    import qrcode
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/qrcode/__init__.py", line 1, in <module>
    from qrcode.main import QRCode
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/qrcode/main.py", line 18, in <module>
    from qrcode.image.base import BaseImage
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/qrcode/image/base.py", line 10, in <module>
    DrawerAliases = Dict[str, Tuple[Type[QRModuleDrawer], Dict[str, Any]]]
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 287, in inner
    return cached(*args, **kwds)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 978, in __getitem__
    return self.copy_with(params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 981, in copy_with
    return _GenericAlias(self.__origin__, params,
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/typing.py", line 874, in __init__
    self.__parameters__ = _collect_type_vars(params)
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/typing_extensions.py", line 198, in _collect_type_vars
    if _should_collect_from_parameters(t):
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/typing_extensions.py", line 172, in _should_collect_from_parameters
    t, (typing._GenericAlias, _types.GenericAlias, _types.UnionType)
AttributeError: module 'types' has no attribute 'UnionType'
6vision commented 1 month ago

python版本是否是3.7以上,必装依赖是否都装成功了?

base0225 commented 1 month ago

python版本是否是3.7以上,必装依赖是否都装成功了?

我重新删除了本地的 python,用的是 python3.8 ,现在可以了,之前试过了 3.10 和 3.12 都不行。

感谢您的回答::)