I have found the solution here:
Python: py2exe loses file path information
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?
Lösung 2
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