Python: py2exe loses file path information

alwbtc

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?

alwbtc

I have found the solution here:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Building an executable file for python code using py2exe

From Dev

Python: Is original source code viewable when converting a python script to .exe file using py2exe?

From Dev

how to use py2exe packing python+gevent program into .exe file?

From Dev

Can we do file handling from executable created by py2exe in Python?

From Dev

"File not found" error with py2exe

From Dev

Py2Exe generate log file

From Dev

py2exe No such file or directory

From Dev

Python, pygame, py2exe

From Dev

Python, pygame, py2exe

From Dev

py2exe error with Python 3.4: Errno2 , missing file 'run-py3 .4-win32.exe'

From Dev

py2exe error with Python 3.4: Errno2 , missing file 'run-py3 .4-win32.exe'

From Dev

Image is not displayed in pyside exe file by py2exe

From Dev

Export Python to exe with "py2exe", Selenium error

From Dev

python py2exe: exe creation/errors

From Dev

Py2exe, Tkinter, and Setup File Problems?

From Dev

py2exe - Create single executable file out of a folder

From Dev

Missing file in compiled py2exe app selenium

From Dev

Create a single-file executable using py2exe

From Dev

Py2Exe file closing at end, probably due to

From Dev

py2exe executes file but doesn't attempt to build

From Dev

Python Flask - Building the Server as Executable (Py2exe)

From Dev

py2exe 64 bit python 2.7 installation

From Dev

Problems on Windows Service written in python and py2exe

From Dev

Python py2exe Not Including `os` Module

From Dev

Using third-party library in py2exe single EXE file

From Dev

Py2exe: Import error when executes created exe file

From Dev

Py2Exe: avoid windows to request permission to execute .exe file

From Dev

Python Pygame RTS py2exe error pygame2exe not working

From Dev

"maximum recursion depth exceeded" while packaging py file with py2exe

Related Related

  1. 1

    Building an executable file for python code using py2exe

  2. 2

    Python: Is original source code viewable when converting a python script to .exe file using py2exe?

  3. 3

    how to use py2exe packing python+gevent program into .exe file?

  4. 4

    Can we do file handling from executable created by py2exe in Python?

  5. 5

    "File not found" error with py2exe

  6. 6

    Py2Exe generate log file

  7. 7

    py2exe No such file or directory

  8. 8

    Python, pygame, py2exe

  9. 9

    Python, pygame, py2exe

  10. 10

    py2exe error with Python 3.4: Errno2 , missing file 'run-py3 .4-win32.exe'

  11. 11

    py2exe error with Python 3.4: Errno2 , missing file 'run-py3 .4-win32.exe'

  12. 12

    Image is not displayed in pyside exe file by py2exe

  13. 13

    Export Python to exe with "py2exe", Selenium error

  14. 14

    python py2exe: exe creation/errors

  15. 15

    Py2exe, Tkinter, and Setup File Problems?

  16. 16

    py2exe - Create single executable file out of a folder

  17. 17

    Missing file in compiled py2exe app selenium

  18. 18

    Create a single-file executable using py2exe

  19. 19

    Py2Exe file closing at end, probably due to

  20. 20

    py2exe executes file but doesn't attempt to build

  21. 21

    Python Flask - Building the Server as Executable (Py2exe)

  22. 22

    py2exe 64 bit python 2.7 installation

  23. 23

    Problems on Windows Service written in python and py2exe

  24. 24

    Python py2exe Not Including `os` Module

  25. 25

    Using third-party library in py2exe single EXE file

  26. 26

    Py2exe: Import error when executes created exe file

  27. 27

    Py2Exe: avoid windows to request permission to execute .exe file

  28. 28

    Python Pygame RTS py2exe error pygame2exe not working

  29. 29

    "maximum recursion depth exceeded" while packaging py file with py2exe

HotTag

Archive