python-dotenv: ImportError: cannot import name load_dotenv
I’ve been getting this error on a python 2.7 installation:
ImportError: cannot import name load_dotenv
any word on what gives?
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 9
- Comments: 34 (6 by maintainers)
@cnicodeme the correct install command is:
You can simply fix this by
Let me know if that helps!
Cheers!
Ok for future peoples that get here, the
load_dotenvhas been removed.Do this instead :
After uninstall dotenv, for my case it still didn’t work. However, it works after I reinstall python-dotenv.
I also got the error
ImportError: cannot import name load_dotenvwhen using Python 3.6 after installing https://github.com/theskumar/python-dotenv version 0.6.4 to withpip install python_dotenv.I gave up and tried https://github.com/mattseymour/python-env version 1.0.0 instead, which I installed with
pip install python-env. I used it in my file as follows, and it worked successfully without any issues:@cnicodeme that’s kind of strange as
Dotenvwas never part of this library. Are you sure, the library that you are using is python-dotenv and not something else.It would really helpful if you can post the output of your
pip freezecommand and/orThanks,
@sirvon well make sure you have activated your
virtualenvif you are using this inside it.sudo apt install python3-dotenvworked for me in a Hyper-V virtual machine with Ubuntu 18.04Uninstall dotenv and python-dotenv
sudo pip uninstall dotenv && sudo pip uninstall python-dotenvthen install the python-dotenvsudo pip install python-dotenvThis really works
@shaunakmukherjee try uninstalling and installing
pip install python-dotenv.Best option would be to create and try inside a virtualenv.