I am trying to create a simple standalone script with pyinstaller. The script only uses pandas and pdfminer packages. I have also created a fresh environment with only these two packages and their dependencies installed.
I get the below error when running pyinstaller --onefile ema_pdf_reader.spec and my .spec file looks like this:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['ema_pdf_reader.py'],
pathex=['/home/erik/PycharmProjects/simple_gui'],
binaries=[],
datas=[],
hiddenimports=['pandas','pdfminer'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='ema_pdf_reader',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
ERROR:
(clean_env) [erik@liara simple_gui]$ pyinstaller --onefile ema_pdf_reader.spec
34 INFO: PyInstaller: 3.6
34 INFO: Python: 3.8.2 (conda)
69 INFO: Platform: Linux-5.10.15-1-MANJARO-x86_64-with-glibc2.10
72 INFO: UPX is not available.
73 INFO: Extending PYTHONPATH with paths
['/home/erik/PycharmProjects/simple_gui',
'/home/erik/PycharmProjects/simple_gui']
73 INFO: checking Analysis
73 INFO: Building Analysis because Analysis-00.toc is non existent
73 INFO: Initializing module dependency graph...
74 INFO: Caching module graph hooks...
78 INFO: Analyzing base_library.zip ...
2247 INFO: Processing pre-find module path hook distutils
2247 INFO: distutils: retargeting to non-venv dir '/home/erik/miniconda3/envs/clean_env/lib/python3.8'
4327 INFO: Caching module dependency graph...
4424 INFO: running Analysis Analysis-00.toc
4448 INFO: Analyzing ema_pdf_reader.py
5378 INFO: Processing pre-safe import module hook six.moves
6929 INFO: Processing pre-find module path hook site
6929 INFO: site: retargeting to fake-dir '/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/fake-modules'
12802 INFO: Processing module hooks...
12802 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
12803 INFO: Loading module hook "hook-numpy.py"...
12803 INFO: Loading module hook "hook-pytz.py"...
12816 INFO: Loading module hook "hook-pandas.py"...
13457 INFO: Loading module hook "hook-distutils.py"...
13459 INFO: Loading module hook "hook-pkg_resources.py"...
13672 INFO: Processing pre-safe import module hook win32com
13879 WARNING: Hidden import "pkg_resources.py2_warn" not found!
13881 INFO: Excluding import '__main__'
13882 INFO: Removing import of __main__ from module pkg_resources
13883 INFO: Loading module hook "hook-pydoc.py"...
13883 INFO: Loading module hook "hook-_tkinter.py"...
13974 INFO: checking Tree
13979 INFO: checking Tree
13983 INFO: Loading module hook "hook-sysconfig.py"...
13993 INFO: Loading module hook "hook-cryptography.py"...
14149 INFO: Loading module hook "hook-setuptools.py"...
14570 INFO: Loading module hook "hook-encodings.py"...
14619 INFO: Loading module hook "hook-lib2to3.py"...
14621 INFO: Loading module hook "hook-sqlite3.py"...
14665 INFO: Loading module hook "hook-numpy.core.py"...
14666 INFO: MKL libraries found when importing numpy. Adding MKL to binaries
14667 INFO: Loading module hook "hook-xml.py"...
14790 INFO: Looking for ctypes DLLs
Traceback (most recent call last):
File "/home/erik/miniconda3/envs/clean_env/bin/pyinstaller", line 11, in <module>
sys.exit(run())
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/__main__.py", line 114, in run
run_build(pyi_config, spec_file, **vars(args))
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/__main__.py", line 65, in run_build
PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 734, in main
build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 681, in build
exec(code, spec_namespace)
File "ema_pdf_reader.spec", line 6, in <module>
a = Analysis(['ema_pdf_reader.py'],
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 244, in __init__
self.__postinit__()
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/building/datastruct.py", line 160, in __postinit__
self.assemble()
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/building/build_main.py", line 440, in assemble
ctypes_binaries = scan_code_for_ctypes(co)
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/depend/utils.py", line 143, in scan_code_for_ctypes
binaries = _resolveCtypesImports(binaries)
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/depend/utils.py", line 317, in _resolveCtypesImports
load_ldconfig_cache()
File "/home/erik/miniconda3/envs/clean_env/lib/python3.8/site-packages/PyInstaller/depend/utils.py", line 400, in load_ldconfig_cache
path = m.groups()[-1]
AttributeError: 'NoneType' object has no attribute 'groups'
Do I need to specify some other settings in my .spec file? So far I just added external packages to hiddenimports, rest of the .spec file was auto generated with pyi-makespec --onefile ema_pdf_reader.py
Script by it self runs fine and creating standalone scripts that only use standard libraries also works with no problem.
UPDATE 1:
The error must be due to ctype DLL detection. It happens when importing numpy as well. I have tried with different versions of pyinstaller (3.6 and 4.2) and the error persists. I also tried reinstalling pyinstaller with pip instead of conda and it didn't help.
UPDATE 2: Executing same procedure on a windows machine works as expected