0

I have a script which downloads a file and saves to the Pictures directory.

all is working well and I set that script to run on start up. but Since then I am getting key-error i.e HOME key.

line where I getting error:

filepath=os.environ['HOME']+'//Pictures'

but it works fine when I run that script normally.

why is this happening?

Harry
  • 33
  • 1
  • 9
  • how are you setting your HOME environment variable? Maybe you need to export it in bashrc or profile so it is set on startup. – user1427258 Oct 15 '17 at 07:19
  • Why are you not using the proper XDG method for getting the appropriate directory? – Ignacio Vazquez-Abrams Oct 15 '17 at 07:22
  • It is probably because your system didn't initialize the $HOME environment variable yet, or it points to a location which "Pictures" is not exists in. It is highly depends on where you put your script in and in what stage it is been executed. I'd suggest you to use hard coded path to the folder or alternatively, to execute the script in other way (`.bashrc` for example). – Megabeets Oct 15 '17 at 07:28

1 Answers1

0

It might be related to the fact of user startup, as the $HOME directory is related to a specific user. You maybe want to add to bashrc some default $HOME, in case the user wasn't initialised yet.

Fabio
  • 31
  • 8