py2exe、sqlalchemy和cx\u oracle:ImportError:没有命名的模块

2024-10-01 11:19:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用py2exe创建一个二进制文件,下面是py2exe输出的最后几行:

*** 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脚本运行得很好,但是当我执行结果二进制时,我得到以下结果:

^{pr2}$

还有,这是我的设置.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'}]
      )

你知道这是什么意思吗? 提前谢谢。在


Tags: appsandtoyouwindowsdistdocumentsdll
2条回答

只需添加导入sqlalchemy.方言.oracle在你的主模块的顶部。在

您可能需要显式地指定py2exe以使用packages选项导入包。一个很好的检查方法是查看build目录,看到的oracle模块实际上就在那里。在

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

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

相关问题 更多 >