Thanks Christopher. That worked a treat, though that Stackoverflow article 
got s bit confusing when you read down it a bit. Thank you for the help.

Judd

On Wednesday, June 4, 2025 at 5:36:51 PM UTC-4 Chris Barker wrote:

> I think you need to special-case when it's frozen:
>
> # determine if application is a script file or frozen exeif getattr(sys, 
> 'frozen', False):
>     application_path = os.path.dirname(sys.executable)elif __file__:
>     application_path = os.path.dirname(__file__)
>
> from:
>
>
> https://stackoverflow.com/questions/404744/determining-application-path-in-a-python-exe-generated-by-pyinstaller
>
> On Wed, Jun 4, 2025 at 1:17 PM Judd Gledhill <juddrg...@gmail.com> wrote:
>
>> Hello,
>>
>> I am converting some small scripts to exe files to host on a Citrix 
>> server. I am hoping to be able to get the path to the .exe file so I can 
>> traverse to folders next to the exe file itself. Right now I use:
>>
>> script_path = os.path.abspath(__file__) #path to this script
>>
>> But this fails at runtime with the exe file. I read the notes about 
>> __file__ but do not want to bundle the files into the exe itself. How can I 
>> find the path to the exe that is running?
>>
>> Thanks,
>>
>> Judd
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "PyInstaller" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to pyinstaller...@googlegroups.com.
>> To view this discussion visit 
>> https://groups.google.com/d/msgid/pyinstaller/84bc6f62-3d54-4aef-b6ee-ca8f667f2113n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/pyinstaller/84bc6f62-3d54-4aef-b6ee-ca8f667f2113n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>
>
> -- 
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> chris....@noaa.gov
>

-- 
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pyinstaller+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/pyinstaller/c1daa857-5db2-4e8f-9e22-23000bd37df2n%40googlegroups.com.

Reply via email to