1

My python script runs fine, but the executable compiled with Pyinstaller produces a PicklingError. I am using Anaconda to write my scripts, and Anaconda prompt to run the Pyinstaller.I am using Python: 3.8.5 (conda), and Platform: Windows-10-10.0.18362-SP0. The problem appears to be caused by dill.dump_session('Test.txt'), and I was able to confirm this by writing a short test script:

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

Here is the full traceback error that occurs when I run the executable from Anaconda prompt:

  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, in dump
  File "pickle.py", 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 558, in save
  File "dill\_dill.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 558, in save
  File "dill\_dill.py", line 1373, in save_type
  File "pickle.py", line 690, in save_reduce
  File "pickle.py", line 558, in save
  File "pickle.py", line 899, in save_tuple
  File "pickle.py", line 558, in save
  File "pickle.py", line 884, in save_tuple
  File "pickle.py", line 558, in save
  File "dill\_dill.py", line 1390, in save_type
  File "pickle.py", 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

Here is the logging information given by 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.

I tried using the latest developmental version of Pyinstaller (pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip), which produced a slightly different traceback error. This error suggests the problem could be due to multithreading. However, I am not using multithreading in this script. Here is the error message that results when I try to run the executable from Anaconda prompt:

Traceback (most recent call last):
  File "Test.py", line 10, in <module>
  File "dill\_dill.py", line 351, in dump_session
  File "dill\_dill.py", line 446, in dump
  File "pickle.py", line 485, in dump
  File "pickle.py", line 558, in save
  File "dill\_dill.py", line 1317, in save_module
  File "pickle.py", line 715, in save_reduce
  File "pickle.py", line 558, in save
  File "dill\_dill.py", line 933, in save_module_dict
  File "pickle.py", line 969, in save_dict
  File "pickle.py", line 995, in _batch_setitems
  File "pickle.py", line 558, in save
  File "dill\_dill.py", line 1364, in save_type
  File "pickle.py", line 690, in save_reduce
  File "pickle.py", line 558, in save
  File "pickle.py", line 899, in save_tuple
  File "pickle.py", line 558, in save
  File "pickle.py", line 884, in save_tuple
  File "pickle.py", line 558, in save
  File "dill\_dill.py", line 1381, in save_type
  File "pickle.py", line 1073, 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

When I ran Pyinstaller for the first time, I got:

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

I excluded PyQt5 from my spec file in the Analysis section (excludes=['PyQt5']) and then ran "Pyinstaller Test.spec". Running the executable resulted in the error given above.

Attempt at a solution

I have been attempting to resolve this for several days without any luck.

I have tried different Pyinstaller versions, and tried uninstalling and reinstalling it numerous ways, with no success. I have tried using Pyinstaller versions 4.0, 4.1, 4.2, and 4.3, but they all result in the same error. I have even tried using the most recent developmental version (5.0) with no success. Pyinstaller 4.2 was working several weeks earlier, but now I cannot get it to work without the error. I have tried installing Pyinstaller with conda -c conda-forge Pyinstaller AND pip install Pyinstaller with no luck.

I have tried Googling for a solution, and searching StackOverFlow. Other people have had similar errors: "Can't pickle <class 'X'>: it's not the same object as X," but they have not had this issue with only the Pyinstaller executables.

Kim Harvey
  • 11
  • 2
  • Hi. Do you still experience this kind of error? Could post the complete message again but calling `dill.detect.trace(True)` before `dill.dump_session()`? – leogama May 03 '22 at 13:29
  • I think dill is trying to pickle itself for some reason (it shouldn't). – leogama May 03 '22 at 13:41

0 Answers0