2010-10-20 57 views
2

我試圖創建py2exe二進制,這裏有py2exe輸出的最後幾行:py2exe,SQLAlchemy的和cx_oracle:導入錯誤:沒有模塊命名爲oracle

*** copy dlls *** 
copying C:\Apps\Python27\python27.dll -> C:\Documents and Settings\nikolay.derka 
ch\Desktop\UMTScellsChecking\UMTScellsChecking\dist 
setting sys.winver for 'C:\Documents and Settings\nikolay.derkach\Desktop\UMTSce 
llsChecking\UMTScellsChecking\dist\python27.dll' to 'py2exe' 
copying C:\Apps\Python27\w9xpopen.exe -> C:\Documents and Settings\nikolay.derka 
ch\Desktop\UMTScellsChecking\UMTScellsChecking\dist 
copying C:\Apps\Python27\lib\site-packages\py2exe\run.exe -> C:\Documents and Se 
ttings\nikolay.derkach\Desktop\UMTScellsChecking\UMTScellsChecking\dist\UMTSCell 
Test.exe 
The following modules appear to be missing 
['_scproxy', 'sqlalchemy.cprocessors', 'sqlalchemy.cresultproxy', 'win32api', 'w 
in32con', 'win32pipe'] 

*** binary dependencies *** 
Your executable(s) also depend on these dlls which are not included, 
you may or may not need to distribute them. 

Make sure you have the license if you distribute any of them, and 
make sure you don't distribute files belonging to the operating system. 

    USER32.dll - C:\WINDOWS\system32\USER32.dll 
    SHELL32.dll - C:\WINDOWS\system32\SHELL32.dll 
    WSOCK32.dll - C:\WINDOWS\system32\WSOCK32.dll 
    ADVAPI32.dll - C:\WINDOWS\system32\ADVAPI32.dll 
    WS2_32.dll - C:\WINDOWS\system32\WS2_32.dll 
    KERNEL32.dll - C:\WINDOWS\system32\KERNEL32.dll 

我原來的Python腳本運行得很好,但當我執行生成的二進制文件,我得到如下:

C:\Documents and Settings\nikolay.derkach\Desktop\UMTScellsChecking\UMTScellsChe 
cking\dist>UMTSCellTest.exe 
Traceback (most recent call last): 
    File "UMTSCellTest.py", line 53, in <module> 
    File "sqlalchemy\engine\__init__.pyc", line 244, in create_engine 
    File "sqlalchemy\engine\strategies.pyc", line 46, in create 
    File "sqlalchemy\engine\url.pyc", line 99, in get_dialect 
ImportError: No module named oracle 

而且,這裏是我的setup.py我使用py2exe:

from distutils.core import setup 

import py2exe, sys 

sys.argv.append('py2exe') 

setup(
     options = {"py2exe": { 
     'bundle_files': 2, 
     'compressed': True, 
     'dll_excludes': ['oci.dll']}}, 
     console=[{'script': 'UMTSCellTest.py'}] 
    ) 

任何想法,ImportError可能意味着什麼? 在此先感謝。

回答

1

您可能需要明確指定py2exe以使用packages選項導入程序包。檢查的一個好方法是查看構建目錄,並看到oracle模塊實際上在那裏。

options = dict(optimize=2, 
      bundle_files=2, 
      compressed=True, 
      packages=["oracle"], 
      dll_excludes=['oci.dll']) 

setup_dict['options'] = {"py2exe":options} 
0

只需在主模塊頂部添加導入sqlalchemy.dialects.oracle即可。

相關問題