目录
PyInstaller安装
PyInstaller使用
使用PyInstaller.exe错误及解决
关于sqlite error no such table错误的解决办法
问题:python3:(unicode error) 'utf-8' codec can't decode
打包python exe程序去控制台窗口问题:Hidden import "_cffi_ext.c" not found!
pyinstaller生成exe程序其它计算机上提示故障模块名称:ucrtbase.DLL
PyInstaller是第三方库,能够在Windows、Linux、MacOSX等操作系统下将Python源文件打包(或生成.exe文件)。通过对源文件打包,Python程序可以在没有安装Python的环境中运行,也可以作为一个独立文件方便传递和管理。
命令安装:pip install pyinstaller或pip3 install pyinstaller
离线安装:下载PyInstaller安装文件(.tar.gz格式)并解压,解压文件夹中找到setup.py文件,cmd窗口中将此文件夹设置为当前文件夹:按下键盘shift键,点击鼠标右键,选择“在此处打开命令窗口”,执行:python.exe setup.py install
Anaconda python IDE环境,pyinstaller安装目录:D:\ProgramData\Anaconda3\Lib\site-packages\PyInstaller
将PyInstaller.exe路径(一般情况,D:\ProgramData\Anaconda3\Scripts)加入到系统环境变量。
PyInstaller.exe将py文件打包成exe文件。pyinstaller -f -w pythonfilename,如pyinstaller -f -w aa.py
(1)在PyInstaller目录下新建文件夹myexe,将py文件放入其中;
(2)命令提示符进入到myexe文件夹;
(3)命令提示符输入:pyinstaller -F 文件名.py;注意空格和大小写;例如pyinstaller -F mytest.py
(4)在文件夹内将生成若干文件,其中exe文件在dist文件夹中。
其它命令:
(1)pyinstaller -w mytest.py,生成exe文件在运行时,不会弹出CMD窗口;
(2)pyinstaller --icon=d:\si\sifee.ico -F sifee.py,可为exe文件生成图标。
(3)pyinstaller --ico=D:\pdsi\ico\cal3.ico -F -w d:\pdsi\pdsi.py
总结:在Eric6中用python连接数据库,建立查询表数据,结果出现此错误。我这次出现这个问题,根本原因还是python连的数据库与我用SQLiteStudio工具看到的数据库不是一个数据库。
解决方法:新建一个数据库,数据库存放地址就放在Eric工程文件默认的文件夹内,改入数据表。再连接数据库,建立查询成功了。
db_cnn=sqlite3.connect("db_ave_wage.db")
cur=db_cnn.cursor()
sql="select wage_month from t_avewage where year=2017"
# squ="CREATE TABLE t_avewage1 ( id INT PRIMARY KEY UNIQUE NOT NULL, year INT,wage_year DOUBLE, wage_month DOUBLE)";
cur.execute(sql)
result=cur.fetchall()
vbase1=result[0][0]
print(vbase1)
cur.close()
db_cnn.commit()
db_cnn.close()
具体描述:pyinstaller 命令打包程序(pyinstaller --icon=d:\si\sifee.ico -F sifee.py),控制台窗口提示:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 122:invalid continuation byte
几天前还正常的,更新了局部代码,如加入import matplotlib as mpl语句,重新打包,出现以下问题。
解决:It happens because:
\Lib\site-packages\zmq\backend\cffi\__pycache__\_cffi_ext.c file in ZMQ module declares depending from
PyInstaller try to analyze this
This error message is a center of our problem, because it is given in the system language (may be Russian, German, Mandarin, etc.) and its coding depends from the command-line default code page.
So, my way to solve this problem is very simple. And it doesn't hurting the original PyInstaller script.
Just change your default codepage to UTF-8 with chcp 65001 command.
解决(已验证):#控制台输入:chcp 65001,回车,ok!,再输入命令:pyinstaller --icon=d:\si\sifee.ico -F sifee.py,正常。
关于使用pyinstaller 打包带有matplotlib 等出现UnicodeDecodeError解决方法 - CSDN博客 https://blog.csdn.net/u011529752/article/details/54892488
【转】UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc7 in position 1: invalid continuation 汉字编码 - CSDN博客 https://blog.csdn.net/u011350122/article/details/51192826
python3:(unicode error) 'utf-8' codec can't decode - CSDN博客 https://blog.csdn.net/ch7543658/article/details/44309853
控制台输入(console):chcp 65001
控制台输入(console):pyinstaller --ico=d:\si\sifee.ico -F -w d:\si\sifee.py
无-w参数时,打包正常,有-w参数,打包过程提示错误:
163388 WARNING: Hidden import "d:\programdata\anaconda3\lib\site-packages\zmp\backend\cffi\__pycache__\_cffi_ext.c(209):" not found!
163393 WARNING: Hidden import "_cffi_ext.c" not found!
解决方法(已验证):到相应目录下,能够找到_cffi_ext.c文件。重装pyzmq,控制台输入:pip install pyzmq,问题解决。
kernel - Jupyter Notebook with python 3 not running - Stack Overflow https://stackoverflow.com/questions/44823874/jupyter-notebook-with-python-3-not-running/47067937
python - UnicodeDecodeError: 'utf8' codec can't decode byte 0x9c - Stack Overflow https://stackoverflow.com/questions/12468179/unicodedecodeerror-utf8-codec-cant-decode-byte-0x9c
进入到文件所在目录:
1、按住shift键不放,右键空白处,在此处打开命令窗口。
2、chcp 65001
2、pyinstaller --ico=D:\pdsi\ico\cal3.ico -F -w d:\pdsi\pdsi.py
pyinstaller --ico=D:\Cems\rc\office_chart_ring_1.ico -F -w d:\cems\cems.py
pyinstaller --ico=D:\pdsi\ico\cal3.ico -F -w d:\pdsi\pdsi.py
问题签名:
问题事件名称: APPCRASH
应用程序名: cems.exe
应用程序版本: 0.0.0.0
应用程序时间戳: 5a2e9fe6
故障模块名称: ucrtbase.DLL
故障模块版本: 10.0.10240.16390
故障模块时间戳: 55a5bf73
异常代码: 40000015
异常偏移: 0007d85a
OS 版本: 6.1.7601.2.1.0.256.1
区域设置 ID: 2052
其他信息 1: 1499
其他信息 2: 1499a0d681f4b6aa4f62069ad7b464dd
其他信息 3: 7591
其他信息 4: 759177eba9cea8ecebcbf48ef54417f1
联机阅读隐私声明:
http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0804
如果无法获取联机隐私声明,请脱机阅读我们的隐私声明:
C:\windows\system32\zh-CN\erofflps.txt
用pyinstaller将python程序生成exe程序。打包成exe文件后,在开发环境计算机运行正常。将exe文件copy到其它计算机上,程序假死、退出,故障详细中提示:故障模块名称:ucrtbase.DLL。具体如上:
实际最后解决:
1、库文件丢失是一方面,但不是这次产生此问题的根本原因。
此次问题根本原因:
2、问题原因居然是没有建立d:\cems\csv这个目录引起的。建立目录,正常了。
通过检查问题出现语句,到此地方就出了问题。程序运行的计算机中并没有python语句运行所需要的目录:db.to_csv(r"d:\cems\csv\基本情况.csv")
3、另外需要仔细检查其它语句是否仍有与路径有关的,否则还会导致此信息。
4、查看dll文件版本号:右键点击相关dll文件,在属性里有版本信息。
ucrtbase.dll 免费下载 | DLL-files.com https://cn.dll-files.com/ucrtbase.dll.html
Introducing the Universal CRT | Visual C++ Team Blog https://blogs.msdn.microsoft.com/vcblog/2015/03/03/introducing-the-universal-crt/