2012-09-20 3 views
3

저는 파이썬 (pyodbctkinter)으로 프로그램을 작성했습니다. pyodbc을 사용하여 Microsoft Access 데이터베이스에 연결했습니다.PyInstaller로 컴파일 한 후 시작시 오류 수정 방법 pyodbc가 있습니까?

import pyodbc 

# Microsoft Access Database File 
DBfile = 'GDP.mdb' 
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};DBQ='+DBfile) 

내가 명령 프롬프트 (python myprogram.py)에서 컴파일하기 전에를 시작 아주 잘 작동 :

연결 코드가있다. pyinstaller으로 컴파일 할 때 오류는보고되지 않습니다.

하지만 executabl을 실행하려고하면 2 초 동안 기본 창이 표시되고 사라집니다. , 가지고 새로운

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 


편집
가 첫 번째 오류 사라 : 나는 그것을 실행 파일을 실행 다음과 같은 오류를 보여줍니다 디버그 모드를 켭니다 pyinstaller-d 플래그를 사용


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 
+1

편집 : "긴급한"질문 제목에 환영하지 않습니다. 우리 모두는 바쁜 삶을 살고 있습니다. –

+0

Soory, 네 말이 맞아! – user12345

답변

3

로컬 파일이 아닌 절대 파일 이름을 사용해야합니다.

import os 

try: 
    currdir = os.path.abspath(__file__) 
except NameError: # We are the main py2exe script, not a module 
    import sys 
    currdir = os.path.abspath(os.path.dirname(sys.argv[0])) 
DBfile = os.path.join(currdir, 'GDP.mdb') 
+0

좋아, 내가 해보 겠어 ... 잠시만 기다려주십시오 ... – user12345

+3

저는 서두르지 않습니다. –

+0

@MoolsGang : 아, 메인 스크립트에서 이것을 정의했습니다; 모든 경우에 작동하도록 내 대답을 업데이트했습니다. –