由于 dill.load_session()

问题描述

我的 python 脚本运行良好,但使用 Pyinstaller 编译的可执行文件产生 PicklingError。我使用 Anaconda 编写脚本,Anaconda 提示运行 Pyinstaller。我使用 Python:3.8.5(conda)和平台:Windows-10-10.0.18362-SP0。 问题似乎是由 dill.dump_session('Test.txt') 引起的,我可以通过编写一个简短的测试脚本来确认这一点:

import dill
print('Saving session...')
a = 3
y = 6
dill.dump_session('test.txt')
    
print('Saved session to test.txt')

这是我从 Anaconda 提示符运行可执行文件时发生的完整回溯错误

  File "Test.py",line 166,in <module>
    session,prevIoUsSessionBoolean = loadPrevIoUsSession()
  File "Test.py",line 148,in loadPrevIoUsSession
    dill.dump_session('MACqGasDataimporter.pkl')
  File "dill\_dill.py",line 359,in dump_session
  File "dill\_dill.py",line 454,in dump
  File "pickle.py",line 485,line 558,in save
  File "dill\_dill.py",line 1326,in save_module
  File "pickle.py",line 715,in save_reduce
  File "pickle.py",line 941,in save_module_dict
  File "pickle.py",line 969,in save_dict
  File "pickle.py",line 995,in _batch_setitems
  File "pickle.py",line 1373,in save_type
  File "pickle.py",line 690,in save
  File "pickle.py",line 899,in save_tuple
  File "pickle.py",line 884,line 1390,line 1073,in save_global
_pickle.PicklingError: Can't pickle <class 'ctypes.CDLL'>: it's not the same object as ctypes.CDLL
[15600] Failed to execute script Test

这里是 Pyinstaller 给出的日志信息:

1945 INFO: PyInstaller: 4.3
1945 INFO: Python: 3.8.5 (conda)
1945 INFO: Platform: Windows-10-10.0.18362-SP0
1945 INFO: UPX is not available.
1961 INFO: Extending PYTHONPATH with paths
['C:\\Users\\kharvey\\Documents\\Python documents\\Python Scripts\\Test Script','C:\\Users\\kharvey\\Documents\\Python documents\\Python Scripts\\Gas scripts','C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\Lib\\site-packages']
1992 INFO: checking Analysis
1992 INFO: Building Analysis because Analysis-00.toc is non existent
1992 INFO: Initializing module dependency graph...
2008 INFO: Caching module graph hooks...
2008 WARNING: Several hooks defined for module 'win32ctypes.core'. Please take care they do not conflict.
2023 INFO: Analyzing base_library.zip ...
10925 INFO: Processing pre-find module path hook distutils from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-distutils.py'.
10925 INFO: distutils: retargeting to non-venv dir 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib'
18137 INFO: Caching module dependency graph...
18418 INFO: running Analysis Analysis-00.toc
18433 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by C:\Users\kharvey\Anaconda3\envs\env1\python.exe
18700 INFO: Analyzing Test.py
36944 INFO: Processing pre-safe import module hook six.moves from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-six.moves.py'.
40818 INFO: Processing pre-find module path hook site from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-site.py'.
40818 INFO: site: retargeting to fake-dir 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\fake-modules'
57292 INFO: Analyzing hidden import 'pandas'
92184 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\pre_safe_import_module\\hook-urllib3.packages.six.moves.py'.
229177 INFO: Processing pre-safe import module hook win32com from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\pre_safe_import_module\\hook-win32com.py'.
285753 INFO: Processing module hooks...
285753 INFO: Loading module hook 'hook-argon2.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
285753 INFO: Loading module hook 'hook-bcrypt.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
285753 INFO: Loading module hook 'hook-bokeh.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
288890 INFO: Loading module hook 'hook-certifi.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
288906 INFO: Loading module hook 'hook-cryptography.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
289387 INFO: Loading module hook 'hook-dask.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
289497 INFO: Loading module hook 'hook-docutils.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
297110 INFO: Loading module hook 'hook-h5py.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
297110 INFO: Loading module hook 'hook-IPython.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
297951 INFO: Loading module hook 'hook-jedi.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
300404 INFO: Loading module hook 'hook-jinja2.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
300419 INFO: Loading module hook 'hook-jsonschema.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
300466 INFO: Loading module hook 'hook-llvmlite.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
300466 INFO: Loading module hook 'hook-lxml.etree.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
300466 INFO: Loading module hook 'hook-lxml.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
301620 INFO: Loading module hook 'hook-nacl.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
301652 INFO: Loading module hook 'hook-nbconvert.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
301870 INFO: Loading module hook 'hook-nbformat.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
301976 INFO: Loading module hook 'hook-notebook.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
306733 INFO: Loading module hook 'hook-numba.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
306792 INFO: Loading module hook 'hook-openpyxl.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
307026 INFO: Loading module hook 'hook-pycparser.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
307026 INFO: Loading module hook 'hook-pytest.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
310862 INFO: Loading module hook 'hook-pythoncom.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
311718 INFO: Loading module hook 'hook-pywintypes.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
312531 INFO: Loading module hook 'hook-tables.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
312531 INFO: Loading module hook 'hook-win32com.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
C:\Users\kharvey\Anaconda3\envs\env1\Lib\site-packages\win32com\client\makepy.py:369: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if path is not '' and not os.path.exists(path):
315197 INFO: Loading module hook 'hook-zmq.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
320220 INFO: Loading module hook 'hook-babel.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
320624 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
320640 INFO: Loading module hook 'hook-distutils.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
320640 INFO: Loading module hook 'hook-distutils.util.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
320640 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
320781 INFO: Loading module hook 'hook-gevent.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
321451 INFO: Determining a mapping of distributions to packages...
581090 WARNING: Unable to find package for requirement zope.event from package gevent.
581090 WARNING: Unable to find package for requirement greenlet from package gevent.
581090 WARNING: Unable to find package for requirement zope.interface from package gevent.
581090 INFO: Packages required by gevent:
['setuptools','setuptools','cffi','cffi']
583779 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
583779 INFO: Loading module hook 'hook-importlib_Metadata.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
583794 INFO: Loading module hook 'hook-lib2to3.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
583873 INFO: Loading module hook 'hook-matplotlib.backends.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
584764 INFO:   Matplotlib backend "GTK3Agg": ignored
    backend Gtk3Agg requires cairo
585209 INFO:   Matplotlib backend "GTK3Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
585709 INFO:   Matplotlib backend "MacOSX": ignored
    cannot import name '_macosx' from 'matplotlib.backends' (C:\Users\kharvey\Anaconda3\envs\env1\Lib\site-packages\matplotlib\backends\__init__.py)
587030 INFO:   Matplotlib backend "nbAgg": added
<string>:12: MatplotlibDeprecationWarning:
The matplotlib.backends.backend_qt4agg backend was deprecated in Matplotlib 3.3 and will be removed two minor releases later.
587655 INFO:   Matplotlib backend "Qt4Agg": added
588108 INFO:   Matplotlib backend "Qt4Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
588717 INFO:   Matplotlib backend "Qt5Agg": added
589170 INFO:   Matplotlib backend "Qt5Cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
589860 INFO:   Matplotlib backend "TkAgg": added
590603 INFO:   Matplotlib backend "TkCairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
591391 INFO:   Matplotlib backend "WebAgg": added
592126 INFO:   Matplotlib backend "WX": ignored
    No module named 'wx'
592676 INFO:   Matplotlib backend "WXAgg": ignored
    No module named 'wx'
593208 INFO:   Matplotlib backend "WXCairo": ignored
    No module named 'wx'
593864 INFO:   Matplotlib backend "agg": added
594395 INFO:   Matplotlib backend "cairo": ignored
    cairo backend requires that pycairo>=1.11.0 or cairocffiis installed
595226 INFO:   Matplotlib backend "pdf": added
596073 INFO:   Matplotlib backend "pgf": added
596745 INFO:   Matplotlib backend "ps": added
597448 INFO:   Matplotlib backend "svg": added
598291 INFO:   Matplotlib backend "template": added
599543 INFO: Loading module hook 'hook-matplotlib.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
600076 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
600091 INFO: Loading module hook 'hook-numpy.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
600357 INFO: Import to be excluded not found: 'f2py'
600357 INFO: Loading module hook 'hook-numpy._pytesttester.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
600373 INFO: Loading module hook 'hook-packaging.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
600373 INFO: Loading module hook 'hook-pandas.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
601919 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
601934 INFO: Loading module hook 'hook-PIL.Image.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
603309 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
603325 INFO: Loading module hook 'hook-PIL.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
603372 INFO: Import to be excluded not found: 'FixTk'
603372 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
603387 INFO: Import to be excluded not found: 'FixTk'
603387 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
606293 WARNING: Hidden import "pkg_resources.py2_warn" not found!
606324 WARNING: Hidden import "pkg_resources.markers" not found!
606356 INFO: Loading module hook 'hook-pygments.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
609972 INFO: Loading module hook 'hook-PyQt5.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
610676 WARNING: Hidden import "PyQt5.sip" not found!
610676 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
610801 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
611208 INFO: Loading module hook 'hook-PyQt5.QtSvg.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
611780 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612204 INFO: Loading module hook 'hook-pytz.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612617 INFO: Loading module hook 'hook-scipy.linalg.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612617 INFO: Loading module hook 'hook-scipy.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612617 INFO: Loading module hook 'hook-scipy.sparse.csgraph.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612617 INFO: Loading module hook 'hook-scipy.spatial.transform.rotation.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612617 INFO: Loading module hook 'hook-scipy.special._ellip_harm_2.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612617 INFO: Loading module hook 'hook-scipy.special._ufuncs.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612632 INFO: Loading module hook 'hook-scipy.stats._stats.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
612632 INFO: Loading module hook 'hook-setuptools.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
615081 INFO: Import to be excluded not found: 'setuptools.py33compat'
615081 INFO: Import to be excluded not found: 'setuptools.py27compat'
615081 INFO: Loading module hook 'hook-shelve.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
615081 INFO: Loading module hook 'hook-sphinx.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
629302 INFO: Loading module hook 'hook-sqlalchemy.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
629678 INFO:   Found 4 sqlalchemy hidden imports
629678 WARNING: Hidden import "MysqLdb" not found!
629678 WARNING: Hidden import "psycopg2" not found!
640186 WARNING: Hidden import "sqlalchemy.sql.functions.func" not found!
640218 INFO: Loading module hook 'hook-sqlite3.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
640436 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
640436 INFO: Loading module hook 'hook-wcwidth.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
640452 INFO: Loading module hook 'hook-xml.dom.domreg.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
640452 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
640452 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
640452 INFO: Loading module hook 'hook-zope.interface.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
640468 INFO: Loading module hook 'hook-lxml.isoschematron.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
640499 INFO: Loading module hook 'hook-lxml.objectify.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
640499 INFO: Loading module hook 'hook-setuptools.msvc.py' from 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks'...
641168 INFO: Looking for ctypes DLLs
642318 INFO: Analyzing run-time hooks ...
642396 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
642412 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32api.py'
642412 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
642428 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_win32comgenpy.py'
642428 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyqt5.py'
642428 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_traitlets.py'
642443 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\rthooks\\pyi_rth_certifi.py'
642443 INFO: Including run-time hook 'C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_mplconfig.py'
642599 INFO: Looking for dynamic libraries
647209 INFO: Looking for eggs
647209 INFO: Using Python library C:\Users\kharvey\Anaconda3\envs\env1\python38.dll
647209 INFO: Found binding redirects:
[]
647303 INFO: Warnings written to C:\Users\kharvey\Documents\Python documents\Python Scripts\Test Script\build\Test\warn-Test.txt
648889 INFO: Graph cross-reference written to C:\Users\kharvey\Documents\Python documents\Python Scripts\Test Script\build\Test\xref-Test.html
649809 INFO: Appending 'datas' from .spec
649903 INFO: checking PYZ
649903 INFO: Building PYZ because PYZ-00.toc is non existent
649903 INFO: Building PYZ (ZlibArchive) C:\Users\kharvey\Documents\Python documents\Python Scripts\Test Script\build\Test\PYZ-00.pyz
666186 INFO: Building PYZ (ZlibArchive) C:\Users\kharvey\Documents\Python documents\Python Scripts\Test Script\build\Test\PYZ-00.pyz completed successfully.
666514 INFO: checking PKG
666514 INFO: Building PKG because PKG-00.toc is non existent
666514 INFO: Building PKG (CArchive) PKG-00.pkg
824008 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
824669 INFO: Bootloader C:\Users\kharvey\Anaconda3\envs\env1\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run_d.exe
824669 INFO: checking EXE
824669 INFO: Building EXE because EXE-00.toc is non existent
824669 INFO: Building EXE from EXE-00.toc
824684 INFO: copying icons from ['C:\\Users\\kharvey\\Anaconda3\\envs\\env1\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
824684 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
824684 INFO: Writing RT_ICON 1 resource with 3752 bytes
824684 INFO: Writing RT_ICON 2 resource with 2216 bytes
824684 INFO: Writing RT_ICON 3 resource with 1384 bytes
824684 INFO: Writing RT_ICON 4 resource with 37019 bytes
824684 INFO: Writing RT_ICON 5 resource with 9640 bytes
824684 INFO: Writing RT_ICON 6 resource with 4264 bytes
824684 INFO: Writing RT_ICON 7 resource with 1128 bytes
824684 INFO: Updating manifest in C:\Users\kharvey\Documents\Python documents\Python Scripts\Test Script\build\Test\run_d.exe.mzxydkhf
824700 INFO: Updating resource type 24 name 1 language 0
824700 INFO: Appending archive to EXE C:\Users\kharvey\Documents\Python documents\Python Scripts\Test Script\dist\Test.exe
983293 INFO: Building EXE from EXE-00.toc completed successfully.

我尝试使用 Pyinstaller 的最新开发版本 (pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip),它产生了稍微不同的回溯错误。此错误表明问题可能是由于多线程造成的。但是,我没有在这个脚本中使用多线程。 这是我尝试从 Anaconda 提示符运行可执行文件时产生的错误消息:

Traceback (most recent call last):
  File "Test.py",line 10,in <module>
  File "dill\_dill.py",line 351,line 446,line 1317,line 933,line 1364,line 1381,in save_global
_pickle.PicklingError: Can't pickle <class 'multiprocessing.popen_spawn_win32.Popen'>: it's not the same object as multiprocessing.popen_spawn_win32.Popen
[27048] Failed to execute script Test

当我第一次运行 Pyinstaller 时,我得到:

AttributeError: Module 'PyQt5' has no attribute '__version__'.

我从分析部分的规范文件中排除了 PyQt5(排除 =['PyQt5']),然后运行“Pyinstaller Test.spec”。运行可执行文件导致上述错误

尝试解决方

我已经尝试解决这个问题好几天了,但没有任何运气。

我尝试了不同的 Pyinstaller 版本,并尝试了多种方法卸载和重新安装它,但都没有成功。我曾尝试使用 Pyinstaller 版本 4.0、4.1、4.2 和 4.3,但它们都导致相同的错误。我什至尝试使用最新的开发版本 (5.0),但没有成功。 Pyinstaller 4.2 几周前就可以工作了,但现在我无法在没有错误的情况下让它工作。我尝试使用 conda -c conda-forge Pyinstaller 和 pip install Pyinstaller 安装 Pyinstaller,但没有成功。

我试过谷歌搜索解决方案,并搜索 StackOverFlow。其他人也有类似的错误:“不能腌制 :它与 X 不是同一个对象,”但他们没有遇到这个问题,只有 Pyinstaller 可执行文件

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)