py2exe、sqlalchemy 和 cx_oracle:导入错误:没有名为 oracle 的模块

发布于 2024-09-28 03:05:21 字数 2278 浏览 6 评论 0原文

我正在尝试使用 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 脚本运行得很好,但是当我执行生成的二进制文件时,我得到以下内容:

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 可能意味着什么吗? 提前致谢。

I'm trying to create a binary with py2exe, here are last lines of py2exe output:

*** 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

My original python script runs just fine, but when I execute resulting binary I get the following:

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

Also, here is my setup.py which I use for 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'}]
      )

Any ideas what that ImportError could mean?
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

守不住的情 2024-10-05 03:05:21

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

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

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

You may need to specify explicitly to py2exe to import the package with the packages option. A good way to check is to look in the build directory, and see of the oracle module is actually there.

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

setup_dict['options'] = {"py2exe":options}
等待圉鍢 2024-10-05 03:05:21

只需在主模块顶部添加 import sqlalchemy.dialects.oracle 即可。

Just add import sqlalchemy.dialects.oracle at the top of youre main module.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文