isaackogan / TikTokLive

Python library to receive live stream events (comments, gifts, etc.) in realtime from TikTok LIVE.
https://isaackogan.github.io/TikTokLive/
MIT License
752 stars 154 forks source link

ImportError: cannot import name 'User' from 'TikTokLive.proto' #190

Closed KalvinThien closed 2 months ago

KalvinThien commented 3 months ago

ImportError: cannot import name 'User' from 'TikTokLive.proto' (C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\TikTokLive\proto__init.py) Traceback: File "C:\Users\KalvinThien\AppData\Roaming\Python\Python311\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 535, in _run_script exec(code, module.dict) File "D:\tech_review\edit_video\Ewrite\Full_web\pages\Etool_source\Full_Code_Etools\Live_stream_voice_Ai_Khong_comment.py", line 2, in from TikTokLive.events import ConnectEvent, CommentEvent File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\TikTokLive\events\init__.py", line 3, in from .custom_events import File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\TikTokLive\events\custom_events.py", line 8, in from TikTokLive.events.proto_events import SocialEvent, ControlEvent File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\TikTokLive\events\proto_events.py", line 7, in from TikTokLive.proto.custom_proto import File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\TikTokLive\proto\custom_proto.py", line 7, in from TikTokLive.proto import User, GiftStruct

I am using the final version of TikTokLive. Python 3.11.6 windown 11

thanks for help

KalvinThien commented 3 months ago

from TikTokLive import TikTokLiveClient

from TikTokLive.events import CommentEvent, ConnectEvent await asyncio.sleep(30)

client: TikTokLiveClient = TikTokLiveClient(unique_id=username)

@client.on("connect") async def on_connect(event: ConnectEvent): st.success("Successful connection to ROOM ID: {}".format(client.room_id))

@client.on("comment") async def on_comment(event: CommentEvent):

Update prompt_parts with new comments and return to original content after every reading

            prompt_parts[0] = original_prompt + f" There is a new comment from you with the nick name {event.user.nickname}: {event.comment}?, read through and reply"

st.session_state['latest_comment'] = event.comment st.success(f"{event.user.nickname} -> {event.comment}")

now, i get an error :

AttributeError: 'str' object has no attribute 'get_type' Traceback: File "C:\Users\KalvinThien\AppData\Roaming\Python\Python311\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 535, in _run_script exec(code, module.dict) File "D:\tech_review\edit_video\Ewrite\Full_web\pages\Etool_source\Full_Code_Etools\Live_stream_voice_Ai_Khong_comment.py", line 567, in asyncio.run(main()) File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\nest_asyncio.py", line 30, in run return loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\nest_asyncio.py", line 98, in run_until_complete return f.result() ^^^^^^^^^^ File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\asyncio\futures.py", line 203, in result raise self._exception.with_traceback(self._exception_tb) File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 277, in __step result = coro.send(None) ^^^^^^^^^^^^^^^ File "D:\tech_review\edit_video\Ewrite\Full_web\pages\Etool_source\Full_Code_Etools\Live_stream_voice_Ai_Khong_comment.py", line 466, in main @client.on("connect") ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\KalvinThien\AppData\Local\Programs\Python\Python311\Lib\site-packages\TikTokLive\client\client.py", line 275, in on return super(TikTokLiveClient, self).on(event.get_type(), f) ^^^^^^^^^^^^^^

isaackogan commented 2 months ago

Need more info. Explain your issue. I will not read your stacktrace to guess.