您的位置:首页 > 移动开发 > Objective-C

AttributeError: ‘module’ object has no attribute ‘load_dotenv

2018-03-18 19:17 871 查看

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:
dotenv.load_dotenv(os.path.join(MY_CURRENT_PATH,’.env’))
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
help(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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: