Question

My python script saves a file in parent of file path:

desktop = os.path.dirname(os.path.realpath(__file__))
desktop = os.path.abspath(os.path.join(desktop, os.pardir))
file_path = desktop  + "\\" + "text1.txt"

fo = open(file_path, "wb")
fo.write("blabla")
fo.close()

When I turn this python script into exe using py2exe, the path file_path cannot be found. How to prevent this?

Was it helpful?

Solution 2

I have found the solution here:

http://www.py2exe.org/index.cgi/WhereAmI

OTHER TIPS

You have to run py2exe from the place of the modules you are transforming to executables.

edit: more exactly make sure you have your setup.py in that place and run it from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top