Bale
tips: Welcome to my blog Favorites: https://www.fengwenhua.top/
example usespachonggui.py
- Normal execution again
pyinstaller -Fw pachonggui.py
- Script to add a line of code
import PyQt5.sip
And then execute the same command
pyinstaller -Fw pachonggui.py
- Deleted
import PyQt5.sip
, you can continue to write code. If you want to pack, from the1
start
Appeared failed to execute script
investigation methods
Act One:
After the command is completed build\pachonggui\warnpachonggui.txt
, the above will be recorded error
Act II:
# 使用完下面这条指令之后,打开exe,提示failed to execute script
pyinstaller -Fw pachonggui.py
# 然后执行下面这条执行,会在list下生成一个目录,进入该目录,用**命令行**执行该exe,就会看到错误了
pyinstaller -D pachonggui.py
pyinstaller打包使用pyqt5模块的时候,在win平台下,由于pyinstaller无法准确获取QT动态库文件路径,会报错导致无法打开运行程序,并提示错误信息pyinstaller failed to execute script pyi_rth_qt5plugins此时我们需要在打包的时候直接告诉pyinstaller到哪里去找,这个路径分隔符需要是unix形式:
pyinstaller --paths C:/****/Python/Python35-32/Lib/site-packages/PyQt5/Qt/bin -F -w ****.py
pyqt5 packaging issues through
Files are used here
pachonggui.py
, which uses the library pyqt5
Installed pyinstaller
after the first use the following command script package
pyinstaller.exe -Fw .\pachonggui.py
Finished, generate two directories
exe
File dist
directory
Double-click operation appears Failed to execute script pachonggui
an error
Go to the build
directory where to find the warn***.txt
file, which will record some errors
Here you can see, pyqt5
the library is not found
Analysis : Normally, if pyinstaller
is pip3
installed, it pyqt5
should also under the same directory, should not occur can not find the path So, there are two cases, a yes. pyinstaller
Wrong, and one is pyqt5
wrong, here I would like to specify pyqt5
the path to try it
Python3 find the installation path, and I was as follows
Then --path
specify the library catalog, with one caveat: This is used /
as a directory separator, rather than\
pyinstaller.exe --path E:/Python/Python36-32/Lib/site-packages/PyQt5/Qt/bin -Fw .\pachonggui.
py
After re-packaged to run again, reported the same mistakes, look build
at the directory warn***.txt
file, or the same, did not find the PyQt5
library
Since I installed python2.7
and python3.6
, but I just gave python2.7 configure the environment variables, so that the command line there pyinstaller
is a python27
directory, not python36-32
the directory, so to say, then, I use the command prompt where specified python36-32
under the pyinstaller
try
After performing packaging commands, see the command prompt, and a few more things sip not found
, whether it's first, first down, and then continue to run itexe
Yes, this is wrong ... ...
take a lookwarn***.txt
Found pyqt5 successfully imported, the cause of the error before the call to explain it is because python27
the pyinstaller
designated use python36-32
under pyinstaller
gone wrong with
This time warn***.txt
is a lot of things ... ... do not understand how to do?
It does not matter, there are ways to use -D
instruction to the exe and making a directory, then use the command line to run the exe under the new directory, then you should see the reported error
E:\Python\Python36-32\Scripts\pyinstaller.exe -D .\pachonggui.py
This time dist
the directory will be more than a directorypachonggui
Then, in here, I need to use 命令提示符
to run thisexe
The results are as follows:
... ... PyQt5.sip
what stuff ??? I did not use the code inside ah ~~~ !!!
In this case, I decided to manually add the code inside it, and then perform a packaging commands
I do not understand why prompt sip not found
still there, but, this time, exe ready to run, not a bug