rossirm
Posts: 7
Joined: Sat Jul 14, 2018 6:15 pm

How to use relative path to my script...

Tue Aug 07, 2018 3:31 pm

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.

User avatar
The Traveler
Posts: 360
Joined: Sat Oct 21, 2017 3:48 pm

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

Tue Aug 07, 2018 3:49 pm

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)
Retired IT professional, C programmer and "beardie weirdie".
RPi interests: Developing an Infinite Improbability Drive
“Thinking outside of the box allows you to get rewards outside of your reach.” Matshona Dhliwayo

Return to “Python”