pyinstaller failed to execute script

Bale

tips: Welcome to my blog Favorites: https://www.fengwenhua.top/
example usespachonggui.py

  1. Normal execution again
pyinstaller -Fw pachonggui.py
  1. Script to add a line of code
import PyQt5.sip

And then execute the same command

pyinstaller -Fw pachonggui.py
  1. Deleted import PyQt5.sip, you can continue to write code. If you want to pack, from the 1start

Appeared failed to execute scriptinvestigation 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 pyinstallerafter the first use the following command script package

pyinstaller.exe -Fw .\pachonggui.py

Finished, generate two directories

exeFile distdirectory

Double-click operation appears Failed to execute script pachongguian error

Go to the builddirectory where to find the warn***.txtfile, which will record some errors

Here you can see, pyqt5the library is not found

Analysis : Normally, if pyinstalleris pip3installed, it pyqt5should also under the same directory, should not occur can not find the path So, there are two cases, a yes. pyinstallerWrong, and one is pyqt5wrong, here I would like to specify pyqt5the path to try it

Python3 find the installation path, and I was as follows

Then --pathspecify 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 buildat the directory warn***.txtfile, or the same, did not find the PyQt5library

Since I installed python2.7and python3.6, but I just gave python2.7 configure the environment variables, so that the command line there pyinstalleris a python27directory, not python36-32the directory, so to say, then, I use the command prompt where specified python36-32under the pyinstallertry

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 python27the pyinstallerdesignated use python36-32under pyinstallergone wrong with

This time warn***.txtis a lot of things ... ... do not understand how to do?

It does not matter, there are ways to use -Dinstruction 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 distthe directory will be more than a directorypachonggui

Then, in here, I need to use 命令提示符to run thisexe

The results are as follows:

... ... PyQt5.sipwhat 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 foundstill there, but, this time, exe ready to run, not a bug

发布了40 篇原创文章 · 获赞 55 · 访问量 8万+

Guess you like

Origin blog.csdn.net/A807296772/article/details/82769835