wxpython安装2.9安装后提示找不到.exe文件_py2exe生成exe后,运行exe时提示No module named * 的解决办法...

一个pymssql 的程序在解释器上运行正常,但是用py2exe打包后,提示

ImportError: No module named _mssql

百度了半天无果,然后bing,结果bing还是比百度靠谱,某神网的这段话,让我有了灵感,英语真心不怎么好滴说:

FYI there is a separate newsgroup for py2exe at

gmane.comp.python.py2exe. You may want to post

there also.

Just as a suggestion, put an import decimal at

the top of your program. It looks like _mssql

might be doing dynamic imports in __load method

which will "confuse" py2exe because it can't

know about dynamic imports which happen at

runtime.

-Larry Bates

Chris wrote:

I've just completed a project using the following (Windows XP, python

2.4.1, wxpython 2.6, and pymssql 0.7.3). The program runs great, but

after I convert it to an exe (required for this project), it gives me

the following error when I try to run it.

Traceback (most recent call last):

File "EstUpdate.py", line 6, in ?

File "frmSplash.pyc", line 9, in ?

File "pymssql.pyc", line 23, in ?

File "_mssql.pyc", line 9, in ?

File "_mssql.pyc", line 7, in __load

ImportError: No module named decimal

However, when I look in c:\python24\lib on the machine which ran py2exe,

I see decimal.py and decimal.pyc.

Can someone please help with this? I'm supposed to start testing the

program today and I can't seem to move past this first step.

Thanks!!

Chris

解决办法就是这句话:

Just as a suggestion, put an import decimal at

the top of your program. It looks like _mssql

might be doing dynamic imports in __load method

which will "confuse" py2exe because it can't

know about dynamic imports which happen at

runtime.

运行exe的时候提示缺什么模块就import什么模块,并在代码里面显示的调用一次,我在程序里是调用了__version__,如下代码:

1 #-*- coding:gbk -*-

2 importpymssql3 import_mssql4 importuuid5 importdecimal6

7 decimal.__version__

8 uuid.ctypes.__version__

9 _mssql.__version__

调用之后,打包完直接就可以运行了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值