pm494
pm494
2017-08-13 05:59
采纳率: 0%
浏览 8.7k

用pyinstaller封装python3.6脚本,生成的exe无法加载所需的包怎么办?

我已经尝试了各种办法,在创建exe的时候用-p命令添加python\lib\side-package里面我所要用的包的文件夹路径,或者在后面加上--path=,但是生成的exe文件在运行的时候还是会显示这样:

 [15664] PyInstaller Bootloader 3.x
[15664] LOADER: executable is E:\python\exe\dist\Timer.exe
[15664] LOADER: homepath is E:\python\exe\dist
[15664] LOADER: _MEIPASS2 is NULL
[15664] LOADER: archivename is E:\python\exe\dist\Timer.exe
[15664] LOADER: Extracting binaries
[15664] LOADER: Executing self as child
[15664] LOADER: set _MEIPASS2 to C:\Users\pm494\AppData\Local\Temp\_MEI156642
[15664] LOADER: Setting up to run child
[15664] LOADER: Creating child process
[15664] LOADER: Waiting for child process to finish...
[17992] PyInstaller Bootloader 3.x
[17992] LOADER: executable is E:\python\exe\dist\Timer.exe
[17992] LOADER: homepath is E:\python\exe\dist
[17992] LOADER: _MEIPASS2 is C:\Users\pm494\AppData\Local\Temp\_MEI156642
[17992] LOADER: archivename is E:\python\exe\dist\Timer.exe
[17992] LOADER: SetDllDirectory(C:\Users\pm494\AppData\Local\Temp\_MEI156642)
[17992] LOADER: Already in the child - running user's code.
[17992] LOADER: manifestpath: C:\Users\pm494\AppData\Local\Temp\_MEI156642\Timer.exe.manifest
[17992] LOADER: Activation context created
[17992] LOADER: Activation context activated
[17992] LOADER: Python library: C:\Users\pm494\AppData\Local\Temp\_MEI156642\python36.dll
[17992] LOADER: Loaded functions from Python library.
[17992] LOADER: Manipulating environment (sys.path, sys.prefix)
[17992] LOADER: Pre-init sys.path is C:\Users\pm494\AppData\Local\Temp\_MEI156642\base_library.zip;C:\Users\pm494\AppData\Local\Temp\_MEI156642
[17992] LOADER: sys.prefix is C:\Users\pm494\AppData\Local\Temp\_MEI156642
[17992] LOADER: Setting runtime options
[17992] LOADER: Bootloader option: pyi-windows-manifest-filename Timer.exe.manifest
[17992] LOADER: Initializing python
[17992] LOADER: Overriding Python's sys.path
[17992] LOADER: Post-init sys.path is C:\Users\pm494\AppData\Local\Temp\_MEI156642\base_library.zip;C:\Users\pm494\AppData\Local\Temp\_MEI156642
[17992] LOADER: Setting sys.argv
[17992] LOADER: setting sys._MEIPASS
[17992] LOADER: importing modules from CArchive
[17992] LOADER: extracted struct
[17992] LOADER: callfunction returned...
[17992] LOADER: extracted pyimod01_os_path
[17992] LOADER: callfunction returned...
[17992] LOADER: extracted pyimod02_archive
[17992] LOADER: callfunction returned...
[17992] LOADER: extracted pyimod03_importers
[17992] LOADER: callfunction returned...
[17992] LOADER: Installing PYZ archive with Python modules.
[17992] LOADER: PYZ archive: out00-PYZ.pyz
[17992] LOADER: Running pyiboot01_bootstrap.py
[17992] LOADER: Running pyi_rth_win32comgenpy.py
[17992] LOADER: Running Timer.py
Traceback (most recent call last):
  File "Timer.py", line 24, in <module>
ModuleNotFoundError: No module named 'logilib'
[17992] Failed to execute script Timer
[17992] LOADER: OK.
[17992] LOADER: Cleaning up Python interpreter.
[15664] LOADER: Back to parent (RC: -1)
[15664] LOADER: Doing cleanup
[15664] LOADER: Freeing archive status for E:\python\exe\dist\Timer.exe

我尝试在另一台装有python3.5和要用的包的电脑上使用pyinstaller,按照同样的方法生成exe,运行结果是一样的。我看了看代码中的24行是加载BeautifulSoup命令:from bs4 import BeautifulSoup

谷歌看了半天也找到合适的解决办法,求大神帮我看看到底是怎么回事?

pyinstaller运行过程是这样的:

 E:\python\exe>pyinstaller -F -d Timer.py --path=E:/python/exe/Lib;E:/python/exe/Lib/site-package;E:/python/exe/Lib/site-packages/xlwings;E:/python/exe/Lib/site-packages/bs4;E:/python/exe/Lib/site-packages/selenium
5 WARNING: Internal error: early pywin32 import was introduced
63 INFO: PyInstaller: 3.2.1
63 INFO: Python: 3.6.2
64 INFO: Platform: Windows-10-10.0.14393-SP0
66 INFO: wrote E:\python\exe\Timer.spec
68 INFO: UPX is not available.
71 INFO: Extending PYTHONPATH with paths
['E:\\python\\exe',
 'E:\\python\\exe\\Lib',
 'E:\\python\\exe\\Lib\\site-package',
 'E:\\python\\exe\\Lib\\site-packages\\xlwings',
 'E:\\python\\exe\\Lib\\site-packages\\bs4',
 'E:\\python\\exe\\Lib\\site-packages\\selenium',
 'E:\\python\\exe']
75 INFO: checking Analysis
76 INFO: Building Analysis because out00-Analysis.toc is non existent
77 INFO: Initializing module dependency graph...
80 INFO: Initializing module graph hooks...
82 INFO: Analyzing base_library.zip ...
2889 INFO: running Analysis out00-Analysis.toc
2892 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by D:\workapp\Python\python.exe
3230 INFO: Caching module hooks...
3234 INFO: Analyzing E:\python\exe\Timer.py
4930 INFO: Processing pre-safe import module hook   win32com
6402 INFO: Loading module hooks...
6402 INFO: Loading module hook "hook-encodings.py"...
6488 INFO: Loading module hook "hook-pydoc.py"...
6489 INFO: Loading module hook "hook-pythoncom.py"...
6706 INFO: Loading module hook "hook-pywintypes.py"...
6915 INFO: Loading module hook "hook-selenium.py"...
6920 INFO: Loading module hook "hook-win32com.py"...
6920 INFO: Loading module hook "hook-xml.dom.domreg.py"...
6921 INFO: Loading module hook "hook-xml.py"...
6940 INFO: Looking for ctypes DLLs
7045 WARNING: library coredll required via ctypes not found
7054 INFO: Analyzing run-time hooks ...
7058 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
7067 INFO: Looking for dynamic libraries
7380 INFO: Looking for eggs
7381 INFO: Using Python library D:\workapp\Python\python36.dll
7382 INFO: Found binding redirects:
[]
7389 INFO: Warnings written to E:\python\exe\build\Timer\warnTimer.txt
7401 INFO: checking PYZ
7401 INFO: Building PYZ because out00-PYZ.toc is non existent
7403 INFO: Building PYZ (ZlibArchive) E:\python\exe\build\Timer\out00-PYZ.pyz
8492 INFO: Building PYZ (ZlibArchive) E:\python\exe\build\Timer\out00-PYZ.pyz completed successfully.
8503 INFO: checking PKG
8503 INFO: Building PKG because out00-PKG.toc is non existent
8504 INFO: Building PKG (CArchive) out00-PKG.pkg
11271 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
11275 INFO: Bootloader D:\workapp\Python\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run_d.exe
11275 INFO: checking EXE
11276 INFO: Building EXE because out00-EXE.toc is non existent
11278 INFO: Building EXE from out00-EXE.toc
11279 INFO: Appending archive to EXE E:\python\exe\dist\Timer.exe
11288 INFO: Building EXE from out00-EXE.toc completed successfully.

刚刚试了一下另一个包,发现问题可能就是出在脚本中的bs4上面,在加载另一个包的时候并没有问题,程序可以运行。所以为什么是bs4这个包?到底该怎么找到问题呢?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

相关推荐