Frage

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?

War es hilfreich?

Lösung 2

I have found the solution here:

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

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top