Sep-04-2019, 10:56 AM
going back to the question of the paths (it has nothing to do with latest error) for db and text files
where do you want to create the database? I may have mislead you when refer to _MEIPASS and I apologise if that is the case
look at the sample script that is provided in the pyinstaller docs
the output is
where do you want to create the database? I may have mislead you when refer to _MEIPASS and I apologise if that is the case
look at the sample script that is provided in the pyinstaller docs
import sys, os frozen = 'not' if getattr(sys, 'frozen', False): # we are running in a bundle frozen = 'ever so' bundle_dir = sys._MEIPASS else: # we are running in a normal Python environment bundle_dir = os.path.dirname(os.path.abspath(__file__)) print( 'we are',frozen,'frozen') print('__file__ is', __file__) print('__file__ abspath is', os.path.abspath(__file__)) print( 'bundle dir is', bundle_dir ) print( 'sys.argv[0] is', sys.argv[0] ) print( 'sys.executable is', sys.executable ) print( 'os.getcwd is', os.getcwd() ) input()I have it as pypaths.py in c:\sandbox\pypaths.py
Output:we are not frozen
__file__ is c:/sandbox/pypaths.py
__file__ abspath is c:\sandbox\pypaths.py
bundle dir is c:\sandbox
sys.argv[0] is c:/sandbox/pypaths.py
sys.executable is C:\Program Files (x86)\Python37-32\python.exe
os.getcwd is C:\sandbox
if I freeze it and run the exe from C:\sandbox\pypaths.exethe output is
Output:we are ever so frozen
__file__ is pypaths.py
__file__ abspath is C:\sandbox\pypaths.py
bundle dir is C:\Users\***\AppData\Local\Temp\_MEI124082
sys.argv[0] is C:\sandbox\pypaths.exe
sys.executable is C:\sandbox\pypaths.exe
os.getcwd is C:\sandbox
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs