System environmental variable issue

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 ___________________ in
if os.environ[‘SHAREDDIR’]:
…/…/…/virtualenv/python3.7.1/lib/python3.7/ in getitem
raise KeyError(key) from None

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.

Hey @ri-mm,

Can I see your .travis.yml?

language: python

  • “3.7”
    arch: arm64


  • pip install -r requirements.txt


  • touch .env

script: pytest

Hey @rl-mm,

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:

It seems like you’re trying to see if something is present in environ , 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?