I am using Vizard to create an .exe file off a python script. I need this script to create a folder which resides next to the .exe file
if getattr(sys, 'frozen', False):
logging.warning('Application is exe')
loggingPath = os.path.dirname(sys.executable)
logging.warning(os.getcwd())
elif __file__:
loggingPath = os.path.dirname(__file__)
logging.warning('Application is script')
logging.warning(os.getcwd())
if not os.path.exists(loggingFolder):
logging.warning('Directory not existing... creating..')
os.makedirs(loggingFolder)
works fine when I execute from the IDE, but in an exe file it throws data in the Appdata Folder in Windows/Users/Temp/randomfoldername.
Also, I always Application is script, even when its packed into exe.
Can someone point me in the right direction here? Thanks in advance
The sys module does not have any attribute
frozen, which results in the first if statement always returningFalse.sys.executablewill give the path to the python interpreter binary, ie. for Windows the path of yourpython.exefile, which I cannot see why you would need for this.If what you want is to ensure that the file running is a
.exefile, then make a folder next to it, it may be simpler to just check if the filename ends with.exe?