I'm trying to code a simple discord bot in python, but it says i cant import load_dotenv, instead giving me this error:
Traceback (most recent call last):
File "/home/pi/Rotomi/Rotomi.py", line 5, in <module>
from dotenv import load_dotenv
ImportError: cannot import name 'load_dotenv' from 'dotenv' (/home/pi/.local/lib/python3.7/site-packages/dotenv/__init__.py)
For reference, here is my current code: https://pastebin.com/75qru00R
I don't know if this still needs to be solved, but I found out that this worked for me:
from dotenv import dotenv_values
temp = dotenv_values(".env")
TOKEN = temp["DISCORD_TOKEN"]
Just ran into the same issue and luckily we got it solved.
The problem is the package itself. So instead of install package dotenv, what you should install is python-dotenv.
pip install python-dotenv
After that, you code shall work
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With