Awesome pinpoint information It's about the mac terminal. Unverified on windows
I got the full path of the exe file in sys.args [0], so I used it.
When executing the exe file, it seems to decompress it to the user's home directory and execute the process. I wanted to spit out the excel file to the location where the exe was executed, but the excel file is generated in the home directory regardless of the location where the exe file is executed. The python file after decompressing the exe will also be extracted to your home directory.
print(os.path.abspath(__file__)))
# /Users/username/do_something.py
When you make a python command or exec in the terminal, pass the executable file as an argument.
Yeah, isn't it possible to use print (sys.args)
? I thought, I tried it and it came out.
[/Users/username/exe file storage/dist/do_something_exe_file]
After that, if you do the standard operation, it's okay
python
file_path = os.path.join(os.path.dirname(sys.argv[0]), file_name)
I think that it is an industry where basic knowledge and peripheral knowledge are important.