I'm trying to build an executable with pyinstaller using pyinstaller --onefile web_scraper.py and I keep getting this error:
29 INFO: PyInstaller: 4.1
29 INFO: Python: 3.9.2
37 INFO: Platform: macOS-11.2.3-arm64-arm-64bit
37 INFO: wrote /Users/jacobarmiger/dev/comic-list-web-scraper/web_scraper.spec
38 INFO: UPX is not available.
39 INFO: Extending PYTHONPATH with paths
['/Users/jacobarmiger/dev/comic-list-web-scraper',
'/Users/jacobarmiger/dev/comic-list-web-scraper']
42 INFO: checking Analysis
42 INFO: Building Analysis because Analysis-00.toc is non existent
42 INFO: Initializing module dependency graph...
42 INFO: Caching module graph hooks...
45 INFO: Analyzing base_library.zip ...
arch: posix_spawnp: /opt/homebrew/opt/python@3.9/bin/python3.9: Bad CPU type in executable
arch: posix_spawnp: /opt/homebrew/opt/python@3.9/bin/python3.9: Bad CPU type in executable
998 INFO: Processing pre-find module path hook distutils from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks/pre_find_module_path/hook-distutils.py'.
998 INFO: distutils: retargeting to non-venv dir '/opt/homebrew/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9'
2093 INFO: Caching module dependency graph...
2125 INFO: running Analysis Analysis-00.toc
2128 ERROR: Can not find path /usr/lib/libSystem.B.dylib (needed by /opt/homebrew/opt/python@3.9/bin/../Frameworks/Python.framework/Versions/3.9/bin/python3.9)
2129 ERROR: Can not find path /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (needed by /opt/homebrew/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/Python)
2129 ERROR: Can not find path /usr/lib/libSystem.B.dylib (needed by /opt/homebrew/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/Python)
2129 INFO: Analyzing /Users/jacobarmiger/dev/comic-list-web-scraper/web_scraper.py
2174 INFO: Processing pre-safe import module hook urllib3.packages.six.moves from '/opt/homebrew/lib/python3.9/site-packages/PyInstaller/hooks/pre_safe_import_module/hook-urllib3.packages.six.moves.py'.
arch: posix_spawnp: /opt/homebrew/opt/python@3.9/bin/python3.9: Bad CPU type in executable
pre-safe-import-module hook failed, needs fixing.
I see bad CPU in there so I'm thinking that this may be an issue with Apple silicon. I've tried running my terminal with Rosetta and a few other solutions but nothing has worked. Is this an issue with arm64? Here is my project: https://github.com/jacob-armiger/comic-list-web-scraper. I t should be pretty easy to try to execute on your own machine if you wanted to see if it works that way. Also here is my .spec file if that helps:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['web_scraper.py'],
pathex=['/Users/jacobarmiger/dev/comic-list-web-scraper'],
binaries=[],
datas=[],
hiddenimports=[],
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='web_scraper',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )