How to Get the Path of the executing frozen script

前端 未结 3 1745
轮回少年
轮回少年 2021-02-08 18:35

If you are running a frozen python script (frozen using py2exe) from a directory and drive different from where the script is present, what is the best way to determine the path

3条回答
  •  攒了一身酷
    2021-02-08 19:05

    Try this:

    WD = os.path.dirname(os.path.realpath(sys.argv[0]))
    

    That is what I use with cx_Freeze to get the directory from where the .exe is really running.

提交回复
热议问题