tomaarsen / TwitchMarkovChain

Twitch Bot for generating messages based on what it learned from chat
MIT License
118 stars 25 forks source link

Problem with TwitchWebSocket while trying to run MarkovChainBot.py #35

Closed Ursometamorfo closed 1 year ago

Ursometamorfo commented 1 year ago

Hello! I'm a long time user of your program and so far it has been working flawlessly! But recently i formatted my SSD and while trying to set up the bot again i installed Python, Git and ran the requirement.txt command with no problems, but as soon as i tried to run the file MarkovChainBot.py it gave me this error:

Could not find platform independent libraries <prefix>
Traceback (most recent call last):
  File "C:\Users\Administrator\Downloads\TwitchMarkovChain-2.4\TwitchMarkovChain-2.4\MarkovChainBot.py", line 4, in <module>
    from TwitchWebsocket import Message, TwitchWebsocket
  File "C:\Users\Administrator\Downloads\TwitchMarkovChain-2.4\TwitchMarkovChain-2.4\TwitchWebsocket.py", line 8, in <module>
    from TwitchWebsocket.Message import Message
ModuleNotFoundError: No module named 'TwitchWebsocket.Message'; 'TwitchWebsocket' is not a package

I tried to download the TwitchWebSocket myself and copy the message and twitchwebsocket files into the folder but to no avail, rerunning the requirements command just gave back that the requirement was already satisfied, so i'm not sure what's going on or how to fix, any help is highly appreciated!

tomaarsen commented 1 year ago

Hello!

According to your logs, you have a file called TwitchWebsocket.py. This is probably from copying the files locally. When it then tries to do

from TwitchWebsocket.Message import Message

then it'll see TwitchWebsocket as the current file, and there's no Message defined in the current file. Perhaps you could get around this by copying the TwitchWebsocket folder, i.e. this full folder.

However, normally it should work with just pip install TwitchWebsocket, but then make sure there's no local file called TwitchWebsocket.py, or that one will have priority. I think you probably tried that already based on your message. If you run pip show TwitchWebsocket, does it then show a package?

A relatively common error with that is that the pip is from a different python than the python that you're running the program with. You can get around this by doing python -m pip show TwitchWebsocket and python -m pip install TwitchWebsocket. Then you know for sure that the pip and python "match".

Hopefully this helps you in the right direction already, but please let me know if you still can't get it to work, and I'll try to help with some more details.

Ursometamorfo commented 1 year ago

Hi again! THE PROBLEM WAS SOLVED! A quick rundown of my troubleshooting would be:

[2023-05-11 11:04:07,476] [__main__] [INFO    ] - Fetching mod list...
[2023-05-11 11:04:07,699] [__main__] [INFO    ] - Unrecognized command: /mods

Aside from that, it seems it's working as intended!!! Thank you very much for the help and quick answer!

tomaarsen commented 1 year ago

I'm glad that you got it working, despite all that you had to go through to get it to work again!

As for the anomaly, I'm aware of it. Twitch removed most (or all?) of the "slash commands" like /mods. However, it shouldn't affect you - I think it was only used to allow moderators to update the cooldown and disable/enable the bot on the fly from the chat.

tomaarsen commented 1 year ago

I'll close this now :)