re: How to convert .py to .exe? Step by step guide. VIEW POST


Hey buddy, thanks for creating this. I have a problem though: in my python script I call several files that are in the current working directory, based on relative paths to simplify it. Once it's compiled to the exe, it seems that the program goes to the root folder of the computer as an absolute route. This kind of defeats the object since my program has to run in a folder with other files being added and removed.

What can I do to force the .exe to work on relative paths exactly the same way I have my script?



1.What I usually do is get an absolute path so the script\scripts always know where they are

import os
dir = os.path.dirname(__file__)
abs_path = os.path.join(dir, DB_DOCS_NAME)
variable = open(abs_path)

2.If the main script is looking in the wrong place for other scripts then probably your imports are not correct.
Try to use this resource

Hope that I helped in some way

Code of Conduct Report abuse