Page 1 of 1

How to use relative path to my script...

Posted: Tue Aug 07, 2018 3:31 pm
by rossirm
Hi, guys!
I don't know exactly if I use a relative paths instead of absolute ones in my Python scripts if they will be usable when I transfer them on another SD card with the same OS installed on abother Raspberry or the same one. I mean - how my written software on the first SD card would be reusable in a second one and so on. If I put all my programs in a folder not in /home/pi - will this folder if I put it in the same lication on another Raspberry with same hardware features will run my scripts. I also have a Tkinter GUI in my folder with scripts which uses only one script of all in the folder.
Thanks!
My question may be a little messy, excuses for that.

Re: How to use relative path to my script...

Posted: Tue Aug 07, 2018 3:49 pm
by The Traveler
Generally, using relative paths are preferred unless you're 100% sure the file system the script is being copied to is exactly the same. You can find a nice description in the wikipedia article for more information: https://en.wikipedia.org/wiki/Path_(computing)