1.failed to execute scripts xxxx
在网上查了查如何使用pyinstaller后,照猫画虎的写了调命令,其中几个关键点就是 :
1. --path C:\xxxxx\ Lib\site-packages\PyQt5\Qt\bin
命令中一定要加上这条,PyQt5\Qt\bin 是pyqt5的链接库文件,不包括这个文件是
无法打包成EXE的,但是我竟然在安装时,放在了其他文件夹里面,而不是在
Python的安装目录下, 所以如果你也是安装错位置的话,就要搜索此文件夹了
2. 参考https://www.jianshu.com/p/bf07565f0090,添加需要的其他程序模块,我编写
的程序,需要调用一些子模块,所以,要将子模块所在的路径加上,
pyinstaller -Fw -p F:\python35-32\Lib\site-packages;F:\python35-32\Lib\site-pack
ages\matplotlib;F:\python35-32\Lib\site-packages\matplotlib\backends
E:\0E207\soft\Cell_Similarity\CellSim.pyw
3. 最头疼的到了,打包命令完成后,在dist文件夹生成了exe文件,满心欢喜的双击打开,但是弹出的确实failded to execute,尝试修改了几十次都这样,你说崩溃不崩溃,总是如下的报错:
missing module named resource - imported by posix (top-level), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named posix - imported by os (conditional, optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named _posixsubprocess - imported by subprocess (conditional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named readline - imported by cmd (delayed, conditional, optional), code (delayed, conditional, optional), pdb (delayed, optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
excluded module named _frozen_importlib - imported by importlib (optional), importlib.abc (optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named _frozen_importlib_external - imported by importlib._bootstrap (delayed), importlib (optional), importlib.abc (optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named _winreg - imported by platform (delayed, optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named _scproxy - imported by urllib.request (conditional)
missing module named java - imported by platform (delayed), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named ‘java.lang’ - imported by platform (delayed, optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level), xml.sax._exceptions (conditional)
missing module named vms_lib - imported by platform (delayed, conditional, optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named termios - imported by tty (top-level), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level), getpass (optional)
missing module named grp - imported by shutil (optional), tarfile (optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named org - imported by pickle (optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named pwd - imported by posixpath (delayed, conditional), shutil (optional), tarfile (optional), http.server (delayed, optional), webbrowser (delayed), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level), netrc (delayed, conditional), getpass (delayed)
missing module named ‘org.python’ - imported by copy (optional), C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level), xml.sax (delayed, conditional)
missing module named ‘requests.auth’ - imported by C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named requests - imported by C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
missing module named scapy - imported by C:\Users\Brad\PycharmProjects\untitled1\venv\Table_test1.py (top-level)
但是硬着头皮也要去做,调了两天没出来,心态反而放松了,偶然在https://segmentfault.com/q/1010000004934722发现了一点线索,尝试着从pycrypto入手,但是尝试着从pycharm下载pycrypto没有成功,而且从网上下载后也不知道怎么安装,也懒得去研究了,在python的安装盘中搜索 “crypto”,竟然发现了,于是将此文件夹复制到了C:\xxxxx\ Lib\site-packages里面,然后,exe文件就可以执行了!!!
另外,之前我还把request模块从最新版本换成了2.10,还在主程序中加入了
import PyQt5.sip ,但是也不知道这些操作对打包成功有没有作用,也懒得去尝试了,大家可以注意这些细节,祝你打包成功!!!