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__,如下代码:
# -*- coding:gbk -*-
import pymssql
import _mssql
import uuid
import decimal decimal.__version__
uuid.ctypes.__version__
_mssql.__version__
调用之后,打包完直接就可以运行了。
参考地址:http://bytes.com/topic/python/answers/168576-help-py2exe-error-no-module-named-decimal
py2exe生成exe后,运行exe时提示No module named * 的解决办法的更多相关文章
- 在Eclipse中运行Web项目Jsp网页时提示端口被占用的解决办法:Several ports (8005, 8888, 8009) required by Tomcat v9.0 Server at localhost are already in use.
问题: 在Eclipse中运行Web项目Jsp网页启动Tomcat时提示端口被占用: Several ports (8005, 8080, 8009) required by Tomcat v9.0 ...
- Selenium(基于JAVA语言)-》在eclipse上运行web项目在Mac系统上启动时提示nodename nor servname provided解决办法
最近使用eclipse进行自动化测试时,遇到一种情况,无法调起浏览器,且有报错,如下: org.openqa.selenium.WebDriverException: failed to lookup ...
- Aptana Studio 2启动时提示 Workspace Cannot Be Created 解决办法
今天在安装Aptana Studio 2时出现这个东东,卸载后再安装依旧不行最后找到原因 原因 : 就是由于你把“我的文档”的位置修改造成的. 但Aptana还以为 “我的文档”的位置 是在系统的默认 ...
- SQL Server 2008 Express 安装或卸载时提示“重启计算机失败"的解决办法
安装或卸载SQL Server 遇到错误提示:以前的某个程序安装已在安装计算机上创建挂起的文件操作.运行安装程序之前必须重新启动计算机.如下图: 解决办法: 1.在开始->运行中输入regedi ...
- SQL Server 2008 安装或卸载时提示“重启计算机失败"的解决办法(转)
安装或卸载SQL Server 遇到错误提示:以前的某个程序安装已在安装计算机上创建挂起的文件操作.运行安装程序之前必须重新启动计算机.如下图: 解决办法: 1.在开始->运行中输入regedi ...
- yum运行时提示被锁住了解决办法
1.当大家用linux的yum时,是不是经常会遇到下面的情况Loaded plugins: fastestmirrorExisting lock /var/run/yum.pid: another c ...
- sql server 发布时提示'dbo.sysmergepublications'无效的解决办法
对数据库进行数据库复制.订阅时经常会出现各种奇怪的问题 如果你对数据库进行多次发布.删除发布操作时可能会提示“dbo.sysmergepublications”无效的问题, 可以使用以下方法解决: U ...
- flex buider 4.6 打开设计模式(designer)时提示内存不足错误的解决办法
先申明,此方法只适用于flex builder 4.6及以下版本, flex builder 4.7以后已经完全取消了designer功能,是没有办法补救的. 1. 首先下载APE文件,这个文件好像是 ...
- 初始化mysql数据库时提示字符编码错误的解决办法
有时候在安装完数据库并初始化的时候会出现如下错误: root@localhost mysql-5.5.19]# bash scripts/mysql_install_db --user=mysql - ...
随机推荐
- CSAPP--虚拟存储器
虚拟存储器 虚拟存储器(VM)是对主存的一种抽象概念.是硬件一场,硬件地址翻译,贮存,磁盘文件和内核软件的完美交互.他为每个进程提供了一个大的,一致的和私有的地址空间. 它将贮存堪称一个存储在磁盘上的 ...
- JAVA_build_ant_sed
1.简介 sed是非交互式的编辑器.它不会修改文件,除非使用shell重定向来保存结果.默认情况下,所有的输出行都被打印到屏幕上. sed编辑器逐行处理文件(或输入),并将结果发送到屏幕.具体过程如下 ...
- android手机端保存xml数据
1.前面写的这个不能继续插入数据,今天补上,当文件不存在的时候就创建,存在就直接往里面添加数据. 2.代码如下: <pre name="code" class="j ...
- QuickReport多页打印
You use composite reports for this(TQrCompositeReport) on the quickreports tabTake a look in the Dem ...
- logstash nginx 报ArgumentError: comparison of String with 5 failed
80.82.78.38 [23/Sep/2016:05:36:18 +0800] "GET http://www.baidu.com/cache/global/img/gs.gif HTTP ...
- Linux企业级项目实践之网络爬虫(18)——队列处理
所有的URL都接受管理,并在此进行流动.URL从管理模块的存储空间开始,一直到最后输出给磁盘上的URL索引,都由此部分调度.首先,给出URL调度的一般过程,如图所示.其流程的各个具体操作,后面详述.要 ...
- 【转】Win7系统下安装Ubuntu12.04(EasyBCD硬盘安装)--不错
原文网址:http://blog.csdn.net/lengbuleng1107/article/details/14532177 需要的东西有: 1,ubuntu系统镜像,下载地址:http://w ...
- 免费 Bootstrap 管理后台模块下载
在这文章中我们将分享17+个最好的免费 Bootstrap 管理模板.你可以免费下载这些Twitter bootstrap 框架来开发网站后台. SB Admin 2 SB Admin is a fr ...
- hdu3415:最大k子段和,单调队列
题目大意:给定长度为n的数组,求出最大的区间和,其中区间长度在[1,k]之间 分析: 学动态规划的时候我们会遇到一个经典问题 最大子段和,这个题跟最大子段和很类似 不同的是区间的长度有限制,无法用原算 ...
- cocos2dx-lua绑定自定义c++类(一)
本文主要介绍mac上,如何将自定义的c++类,绑定到lua. 1.工具先行 找到 你的cocos2d-x/tools/tolua++,里面文件按类型大致分为: (1)*.pkg:用于定义要绑定的c++ ...