I have a system environmental variable for Box on my computer called SHAREDDIR
This is called in my scripts as SHAREDDIR = os.getenv(‘SHAREDDIR’) and used subsequently to access different files.
However, my build always fails with Travis.
__________________ ERROR collecting test_blackboard.py ___________________
test_blackboard.py:16: in
if os.environ[‘SHAREDDIR’]:
…/…/…/virtualenv/python3.7.1/lib/python3.7/os.py:678: in getitem
raise KeyError(key) from None
E KeyError: ‘SHAREDDIR’
I believe Travis cannot access that folder even though I import the os package initially.
Any help with this will be greatly appreciated. Thank you.
I suggest you check the environment in question for the existence of a variable, say in your case "SHAREDDIR", in Python. One way you could achieve this is by doing:
if os.getenv("SHAREDDIR") is not None:
pass
It seems like you’re trying to see if something is present inenviron , why would you get just to compare it and then toss it away ?
That’s exactly what getenv does. Either way, getenv is just a wrapper around environ.get. So I don’t quite understand what you’re doing. Can you give me your GitHub handle so I can look at the project in it’s entirety?