python-dotenv: Variable not found ("None" returned) on a Mac
Hi, we are using dotenv for a project and are getting strange behavior.
While the environment variable is working just fine on a Windows machine, it is not able to read at all on a Mac. It returns “None” even though the variable is clearly there. There seem to be no other issues.
In X.py file:
from dotenv import load_dotenv
load_dotenv()
import os
HOME_PATH = os.getenv("SQUABBLE_HOME_PATH")
In .env file:
SQUABBLE_HOME_PATH = '/path/to/squabble_runner/'
While running:
Traceback (most recent call last):
File "XXXX/X.py", line 27, in controversy_score
input_file_path = HOME_PATH + 'lib/squabble_input.txt'
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'
This is on Sierra, Python 3.6.2.
As mentioned above, the same code runs just fine on a PC. Any help would be appreciated!
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 18 (4 by maintainers)
I have the same problem as others here. If I use
load_dotenv()then it doesn’t work. If I useload_dotenv(find_dotenv())then it works fine though.It happened to me as well on Docker/Ubuntu14.04. I had to explicitly load with
dotenv_path:@theskumar Can you please reopen the issue? I tested it again with python 3.6.5, as well as with an absolute filename or with the load function, and the issue persists. As opposed to @TDiazT, my file name is definitely .env 😄. No file permission issues either.
Let me know what you need from me in order to reproduce the issue. As I mentioned, this is particularly with one mac and one PC on the same team.
@devrsw, are you still getting the same error?
Thanks!
This is also something we’re running into as well.
Same as well.
Working on High Sierra, Python 3.5
Saw this issue and wanted to post what worked for me since none of the above fixes were working for my problem.
I had trouble getting python-dotenv to work because I had jupyterlab installed in my conda (miniforge) base environment and had installed python-dotenv in a separate environment. python-dotenv wasn’t recognizing the .env file correctly from jupyterlab and after a lot of trouble shooting all I had to do was install python-dotenv in my base conda env as well. Then load_dotenv() correctly recognized my .env file in the same folder as my notebook.
Just wanted to post in case someone else had the same problem.
i’m on a mac, high sierra and I had the same issue until I changed it to:
@theskumar Neither
load_dotenv(find_dotenv())nor providing an absolute path worked.python-dotenv: 0.8.2 Python: 3.6.2 Mac: Sierra