I have writen a program in python (pyodbc
and tkinter
). I used pyodbc
to connect to Microsoft Access Database.
There is the connection Code:
import pyodbc
# Microsoft Access Database File
DBfile = 'GDP.mdb'
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+DBfile)
When I start it before compiling in command prompt (python myprogram.py
) it works very well. When compiling with pyinstaller
all goes well, no errors are reported.
But When trying to launch the executabl it shows the main window for 2 seconds which then disappears.
When I used the -d
flag in pyinstaller
to turn on debug mode it shows the following error when launching the executable:
Traceback (most recent call last):
File "<string>", line 62, in <module>
pyodbc.Error: (
'HY000', "[HY000] [Microsoft][Driver ODBC Microsoft Access]
Can't find File'(Unknown)'.
(-1811) (SQLDriverConnect); [HY000] [Microsoft][Driver ODBC Microsoft Access]
Can't find File'(Unknown)'.
(-1811)")
RC: -1 from main
EDIT
first error gone , got a new one :
Traceback (most recent call last):
File "", line 78, in
File "path\to\my\program\ build\pyi.win32\GDP\outPYZ1.pyz/Tkinter", line 1564, in wm_iconbitmap
_tkinter.TclError: bitmap "icon.ico' not defined
RC: -1 from main
You'll need to use an absolute filename, not a local file:
import os
try:
currdir = os.path.dirname(os.path.abspath(__file__))
except NameError: # We are the main py2exe script, not a module
import sys
currdir = os.path.dirname(os.path.abspath(sys.argv[0]))
DBfile = os.path.join(currdir, 'GDP.mdb')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With