bowhead icon indicating copy to clipboard operation
bowhead copied to clipboard

dotenv.load 'module' object has no attribute 'load'

Open jeremiahtenbrink opened this issue 7 years ago • 12 comments

White going through the tutorial on ubuntu server trying to do the command screen python streaming.py I originally got the error import request not available. after installing python reqest, no clue how I figured that one out, I got the error dotenv not included. did the same as before and now i'm getting the error listed above in the title section. I used pip install dotenv. Uninstalled that one and then used pip install python-dotenv. still no luck. tried django python dotenv. still no luck. I must be doing something wrong. Please help.

jeremiahtenbrink avatar Jul 31 '17 21:07 jeremiahtenbrink

Do you have pip installed and up to date?

there is another option as well, which is the non-streaming version, I made a note about it on the first article.

-joel

On Mon, Jul 31, 2017 at 2:12 PM, jeremiahtenbrink [email protected] wrote:

White going through the tutorial on ubuntu server trying to do the command screen python streaming.py I originally got the error import request not available. after installing python reqest, no clue how I figured that one out, I got the error dotenv not included. did the same as before and now i'm getting the error listed above in the title section. I used pip install dotenv. Uninstalled that one and then used pip install python-dotenv. still no luck. tried django python dotenv. still no luck. I must be doing something wrong. Please help.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/joeldg/bowhead/issues/19, or mute the thread https://github.com/notifications/unsubscribe-auth/AOT1lWAu2Ojdy3-yb9VikApjZ1BTD9sfks5sTkNLgaJpZM4Oo72A .

-- Joel De Gan Vice President of Technology


Mobile: (646) 724-0451 Email: [email protected] Skype: joel-dg

2320 Abbot Kinney Blvd, Suite A Venice, CA 90291 www.RxMG.com http://www.rxmg.com/

rxmg-joeldg avatar Jul 31 '17 23:07 rxmg-joeldg

I get the same error.

python streaming.py
Traceback (most recent call last):
  File "streaming.py", line 90, in <module>
    main()
  File "streaming.py", line 86, in main
    demo(displayHeartbeat)
  File "streaming.py", line 56, in demo
    response = connect_to_stream()
  File "streaming.py", line 28, in connect_to_stream
    dotenv.load()
AttributeError: 'module' object has no attribute 'load'
pip --version
pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

danielbjornadal avatar Aug 05 '17 11:08 danielbjornadal

Observing exactly same pattern - Didn't have requests module and later dotenv module and later no dotenv.load . Did any of you got to debug this issue?

luckymurari avatar Oct 10 '17 17:10 luckymurari

i have made progress on the above error but have run into more. As per dotenv documentation you must now load your .env file like this dotenv_path = join(dirname(__file__), '.env') load_dotenv(dotenv_path)

aleksajovanovic avatar Nov 10 '17 02:11 aleksajovanovic

ok so i fixed a few more errors. The imports need to look like this import requests import json import os from os.path import join, dirname from dotenv import load_dotenv from optparse import OptionParser

and the code for getting the oanda access tokens needs to look like this

access_token = os.getenv('OANDA_TOKEN') account_id = os.getenv('OANDA_ACCOUNT')

aleksajovanovic avatar Nov 10 '17 03:11 aleksajovanovic

sorry for the bad formatting

aleksajovanovic avatar Nov 10 '17 03:11 aleksajovanovic

is this fixed already?

jerome-shiftleft avatar Nov 14 '17 07:11 jerome-shiftleft

I don't have experience with python and I'm getting the same error. Is there a fix for this already? what's the correct format? because as what I'v heard python is strict about spacing and formatting.

tugudush avatar Nov 14 '17 07:11 tugudush

@aleksajovanovic pointed in the right direction, but I still wasn't able to fix it. In order to properly fix it, here's what I did:

  1. Install requests through as per this article. $ sudo pip install requests;
  2. Used the correct dotenv library. You must install sudo pip install python-dotenv. Turns out I had installed it through sudo pip install dotenv and that did not work. See here.
  3. Edited the streaming.py code to match the correct usage of python-dotenv. I have used
from os.path import join, dirname
from dotenv import load_dotenv

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

# load the ENV variables as already done in streaming.py

marcosaccioly avatar Nov 22 '17 10:11 marcosaccioly

You probably installed the wrong dotenv for python. I had the same issue, it was resolved by uninstalling my previously installed dotenv and using this command (as described in the readme): pip install python-env.

JeppeKnockaert avatar Dec 28 '17 13:12 JeppeKnockaert

as Jeppe says, use https://github.com/theskumar/python-dotenv

joeldg avatar Dec 28 '17 16:12 joeldg

I can confirm that pip uninstall python-dotenv and then pip install python-env fixed the problem

webfaqtory avatar Dec 30 '17 14:12 webfaqtory