rundro / discord_spotify

Simple discord bot to add spotify songs to a playlist whenever a spotify link is posted in the chat
3 stars 2 forks source link

no module name 'discord' #1

Open solidspidey opened 1 year ago

solidspidey commented 1 year ago

Hi,

When I try to run script I get the below. How do I fix this?

I am running cmd prompt from folder which includes env.txt file with all of my data.

python main.py Traceback (most recent call last): File "main.py", line 5, in import discord ModuleNotFoundError: No module named 'discord'

rundro commented 1 year ago

you try "pip install discord"? might be pip3 or "python3 -m pip install discord"

solidspidey commented 1 year ago

oh ok, sorry I am python noob, didnt realize have to install dependencies. I just installed discord, Spotipy and dotenv. Now I am seeing this error.

python main.py [2023-09-07 15:49:16] [INFO ] discord.client: logging in using static token Traceback (most recent call last): File "main.py", line 67, in client.run(TOKEN) File "C:\Users\DevM\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 860, in run asyncio.run(runner()) File "C:\Users\DevM\AppData\Local\Programs\Python\Python38\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users\DevM\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete return future.result() File "C:\Users\DevM\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 849, in runner await self.start(token, reconnect=reconnect) File "C:\Users\DevM\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 777, in start await self.login(token) File "C:\Users\DevM\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 609, in login raise TypeError(f'expected token to be a str, received {token.class.name} instead') TypeError: expected token to be a str, received NoneType instead

rundro commented 1 year ago

I advise checking the readme for instructions. the env should be a .env (assuming linux), you would have to set environment variables on Windows. It looks like it's unable to read your token values (env file). You can also optionally hard code them.

solidspidey commented 1 year ago

ok thank you, I'm not a coder or anything and just stumbled upon this via google and trying to add this to one of my discord servers.

I'm on Windows, I guess I have to add a environment variable for .Env? Then maybe the script will read my env.txt file?

SQLaura commented 1 year ago

rename your env.txt file to .env and it should work. The module dotenv should read the content of .env file without depending on the platform.