pyinstaller 将.py生成.exe ----报错 “IndexError: tuple index out of range”
pyinstaller将py打包为exe文件,用pysintaller居然报错
File "c:\anaconda3\lib\site-packages\PyInstaller\depend\utils.py", line 226, in __scan_code_instruction_for_ctypes
name = co.co_names[oparg]
IndexError: tuple index out of range
- 1
- 2
- 3
搜索了一番,用群众神奇的方式
找到D:\python\Python36-32\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py
路径根据安装目录找,上面是我的安装目录
打开modulegraph.py将大约2731附近将
return module_code_object.co_names[co_names_index]
更改为
return co_names_index
#coding by rekfan on 2017/03/21 10:40
#return module_code_object.co_names[co_names_index]
- 1
- 2
- 3
- 4
- 5
重新运行后发现……前一个地方不报错了,又有其他地方报错了,最后追查一圈发现了原因……使用pyinstaller的开发者新版,官网目前的版本是3.2.1 只支持到python3.5 ,恰好我用的Anaconda3装的python是3.6版本的。pyinstaller3.3 还没有发行,但是官网源码里有 https://github.com/pyinstaller/pyinstaller 替换 D:\python\Python36-32\Lib\site-packages\PyInstaller 即可 这样就支持python3.6了 不过是开发版,可能还不完善。
附带pyinstaller的使用方法
pip 安装,国内的源速度飞快
pip install -i https://pypi.douban.com/simple pyinstaller
- 1
然后正常输入pyinstaller -h 可以看到全面的帮助,最常见的把一个py脚本打包成exe就是
确保命令行已经在该文件目录下后输入
pyinstaller -F -c target.py
- 1
-F代表打包成一个exe文件,-c是命令行脚本,如果有GUI则改为-w
具体的参数太多了,直接pyinstaller -h看吧。
===========================================================================================================
1. 错误类型:
ImportError: C extension: No module named ‘pandas._libs.tslibs.timedeltas’ n
2. 错误分析:
因为我的代码中引用了pandas库,然后使用pyinstaller打包的时候显示打包成功,但实际运行过程中显示模块缺失
3. 尝试解决方案:
3.1 删除pandas库重新安装
走外网的pip速度慢的时候,可以使用国内镜像,豆瓣镜像下载
pip install -i https://pypi.douban.com/simple/ packages-name)
- 1
重新安装后,再重新打包依然无法解决问题
3.2 再次百度
CSDN论坛的回答
经测试解决了我的问题。
4. 正式解决方案
修改原有的打包代码为:
pyinstaller -F -w -i xxx.ico yyy.py --hidden-import=pandas._libs.tslibs.timedeltas
- 1
- -F 指只生成一个exe文件,不生成其他dll文件
- -w 不弹出命令行窗口
- -i 设定程序图标 ,其后面的ico文件就是程序图标
- yyy.py 就是要打包的程序
- –hidden-import=pandas._libs.tslibs.timedeltas 隐藏相关模块的引用
======================================================================================================
出现错误原因:安装包的来源问题,也可以理解为包版本兼容问题,有的包使用官方出版,有的包使用whl文件安装
解决方案:将所有包都统一来源,要么全部使用官方出版的包,要么全部使用whl里面的包,问题就解决了
numpy+scipy+scikit-learn组件,使用whl文件安装下载:
http://pan.baidu.com/s/1hstDOo8
第二步:去到Python安装Scripts目录下,再使用pip install xxx.whl安装,先装Numpy\Scipy包,再安装Scikit-Learn。
pyinstaller 将.py生成.exe ----报错 “IndexError: tuple index out of range”的更多相关文章
- python报错IndexError: list index out of range
今天写个ping vpn的python脚本,报错IndexError: list index out of range 最后查看是python读取文件中出现空格 去掉空格即可
- xadmin 数据添加报错: IndexError: list index out of range
报错现象 xadmin 集成到项目后进行添加数据的时候报错 具体如下 黄页 后端 具体报错定位 报错分析 点击这里 报错解决 源码 input_html = [ht for ht in super(A ...
- Py打包exe报错
Py打包exe报错 下载地址 https://github.com/pyinstaller/pyinstaller 用管理员执行 pip install https:/ ...
- 在Windows平台下Qt的exe报错问题排查步骤
在Windows平台下Qt的exe报错问题排查步骤 工具介绍: 1. Dependency Worker Dependency Worker是一个免费的用具用来扫描任何的32bit 或者64bit 的 ...
- 如何解决金蝶IKernel.exe报错 Windows Installer 错误 重新安装、无法卸载
如何解决金蝶IKernel.exe报错 Windows Installer 错误 金蝶这个小婊子,就是这么贱. 卸载了高版本的,再安装低版本就不能安装上,死活都不能安装. 请手动启动一下Install ...
- 用itext生成PDF报错:Font 'STSong-Light1' with 'UniGB-UCS2-H' is not recognized.
用itext生成PDF报错,加上try catch捕获到异常是 BaseFont bFont = BaseFont.createFont("STSong-Light1", &quo ...
- 在数组添加元素时报错:IndexError: list index out of range
今天第一次发随笔还有许多不足之处,欢迎评论!!! 最近在写一个成语接龙的小游戏,结果在数组添加元素时报错:IndexError: list index out of range 源码: import ...
- yii2.0 联表查询数据库报错:undefined index order_id
1.在查询时加了->select();如下,要加上order_id,即关联的字段(比如:order_id)比如要在select中,否则会报错:undefined index order_id / ...
- Python常见错误:IndexError: list index out of range
用python写脚本查询字典时,在遍历字典时循环到某一项时老是报错 出现这种错误有两种情况: 第1种可能情况 list[index]index超出范围 第2种可能情况 list是空值就会出现 In ...
随机推荐
- Java容器有哪些?
网易面试: 问:Java容器有哪些,你聊一聊吧 Java容器: 数组,String,java.util下的集合容器 数组长度限制为 Integer.Integer.MAX_VALUE; String的 ...
- 关于Unity中场景的导入与导出(专题九)
Unity场景 场景虽然是由场景美术做好的,但是我们经常需要自己去导导出以及从别的项目导入,所以我们需要对场景的导入和导出有一个详细的了解 1: 场景是由美术人员搭建完成后提交给程序;2: 场景一般包 ...
- Ogre1.9 源码编译
我们首先需要下载. 1.cmake http://www.cmake.org/download/ (选择window安装包最方便) 2.Ogre1.9源代码 https://bitbucket.org ...
- Python判断操作系统类型
代码: import platform def TestPlatform(): print ("----------Operation System--------------------- ...
- checkbox批量删除功能
参考:http://www.jb51.net/article/35338.htm 感谢作者 代码片段:jsp <c:forEach items="${infolist }" ...
- Ubuntu -- 安装、卸载程序的命令
通过sudo apt-get install xxxx 安装软件后,总是无法卸载干净,这里以Apache 为例,提供方法:首先sudo apt-get remove apache2再sudo apt- ...
- Wings 3D
Wings 3D 编辑 Wings 3D 是一个开源的三维计算机图形软件.使用翼边数据库.注重于多边形建模,构思取与 Izware 的 Nendo 和 Mirai.支持多种操作系统,包括 Linux. ...
- Java 7中的TransferQueue 以及 SynchronousQueue
Java7中加入了JSR 166y规范对集合类和并发类库的改进.其中的一项是增加了接口TransferQueue和其实现类LinkedTransferQueue. TransferQueue继承了Bl ...
- css3实现小箭头,各种图形
转:http://blog.csdn.net/tangtang5963/article/details/51490107 https://segmentfault.com/a/119000000278 ...
- Write operations are not allowed in read-only mode 只读模式下(FlushMode.NEVER/MANUAL)写操作不允
org.springframework.dao.InvalidDataAccessApiUsageException: Write operations are not allowed in read ...