AttributeError: ‘module’ object has no attribute ‘load_dotenv’

I needed to use the dotenv module in Python. I tried the usual

pip install dotenv

Wohoo! I was able to import dotenv without any trouble. It was easy enough to install. Python is so intuitive, right? Well, not in this one case. When I ran my script, I kept getting the error:

AttributeError: ‘module’ object has no attribute ‘load_dotenv’

Eh? dotenv imports fine. So what could the issue be? I launched the Python interpreter and did

import dotenv

Turns out that the dotenv module did not have a load_dotenv method. A little bit of Googling shows that there is another python-dotenv package that also installs the dotenv module. Not cool, Python! So to get past my error, I uninstalled the seemingly intuitive dotenv package and then installed the python-dotenv.

pip uninstall dotenv
pip install python-dotenv

And now my script works.

Arunkumar Muralidharan

I want to find out what conditions produce remarkable software. A few years ago, I chose to work as the first professional tester at a startup. I successfully won credibility for testers and established a world-class team. I have lead the testing for early versions of multiple products. Today, I run Qxf2 Services. Qxf2 provides software testing services for startups. If you are interested in what Qxf2 offers or simply want to talk about testing, you can contact me at: I like testing, math, chess and dogs.


  1. Isaac Karth said:

    I just encountered this issue today, and was very mystified because everything had previously worked. Thanks!

    November 14, 2015
  2. Ganesh said:

    Another way I found out when I got the error dot env module not found, is by downloading the tar for dotenv from python website—>untar–>copy the dotenv folder and drop to Libs folder —> is that one of the right ways?

    Note: I tried the one you have specified above but no luck hence used that approach. Thought it might be useful if it turns out to be a good approach?

    May 13, 2016
    • Annapoorani Gurusamy Annapoorani Gurusamy said:

      Hi Ganesh,The better way to install dotenv is by using pip. Pip is a convenient way to install, upgrade and uninstall modules. You need to manually perform the install, upgrade and uninstall if you use tar files.

      May 16, 2016
  3. Anonymous said:

    OMG, thank you soo much for this fix, I was about to cry

    June 14, 2018
  4. Anonymous said:

    thanks ,
    ——-a boy comes from China

    November 17, 2018
  5. Anonymous said:

    Hey it Works! Thanks man. I was about to lay my comp aside but now that the bug is fixed I’m

    January 25, 2019

Leave a Reply

Your email address will not be published.