#python #pyinstaller
#питон #pyinstaller
Вопрос:
Я создаю приложение для Mac, используя самую последнюю версию Pyinstaller вместе с пакетом анализа сигналов mne. Есть пара файлов данных, один из которых представляет собой изображение, а другой-javascript, которые мне нужно включить в содержимое моего пакета. До сих пор аналитическая часть my .spec выглядит так:
a = Analysis(['main_app.py'], pathex=['/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site- packages'], binaries=[], datas=[('background.png', '.'),('report.js', '.')], hiddenimports=['PIL','sklearn','mne','scipy'], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False)
Файлы в формате datas, background.png и report.js находятся в том же каталоге, что и оба main_app.py и файл .spec, поэтому я использовал точки в своих кортежах выше. (Имя каталога /Users/fishbacp/python_files.)
Pyinstaller создает мое приложение без сообщений об ошибках, но когда я пытаюсь запустить исполняемый файл в командной строке из каталога, содержащего приложение, набрав
./dist/main_app.app/Contents/MacOS/main_app
Я получаю длинное сообщение об ошибке:
File "main_app_11.py", line 4, in lt;modulegt; import mne File "lt;frozen importlib._bootstrapgt;", line 1007, in _find_and_load File "lt;frozen importlib._bootstrapgt;", line 986, in _find_and_load_unlocked File "lt;frozen importlib._bootstrapgt;", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "mne/__init__.py", line 98, in lt;modulegt; File "lt;frozen importlib._bootstrapgt;", line 1007, in _find_and_load File "lt;frozen importlib._bootstrapgt;", line 986, in _find_and_load_unlocked File "lt;frozen importlib._bootstrapgt;", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "mne/report/__init__.py", line 1, in lt;modulegt; File "lt;frozen importlib._bootstrapgt;", line 1007, in _find_and_load File "lt;frozen importlib._bootstrapgt;", line 986, in _find_and_load_unlocked File "lt;frozen importlib._bootstrapgt;", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "mne/report/report.py", line 103, in lt;modulegt; File "pathlib.py", line 1266, in read_text File "pathlib.py", line 1252, in open File "pathlib.py", line 1120, in _opener FileNotFoundError: [Errno 2] No such file or directory: '/Users/fishbacp/python_files/dist/main_app.app/Contents/MacOS/mne/report/js_and_css/report.js' [38982] Failed to execute script 'main_app' due to unhandled exception: [Errno 2] No such file or directory: '/Users/fishbacp/python_files/dist/main_app.app/Contents/MacOS/mne/report/js_and_css/report.js' [38982] Traceback: Traceback (most recent call last): File "main_app.py", line 4, in lt;modulegt; import mne File "lt;frozen importlib._bootstrapgt;", line 1007, in _find_and_load File "lt;frozen importlib._bootstrapgt;", line 986, in _find_and_load_unlocked File "lt;frozen importlib._bootstrapgt;", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "mne/__init__.py", line 98, in lt;modulegt; File "lt;frozen importlib._bootstrapgt;", line 1007, in _find_and_load File "lt;frozen importlib._bootstrapgt;", line 986, in _find_and_load_unlocked File "lt;frozen importlib._bootstrapgt;", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "mne/report/__init__.py", line 1, in lt;modulegt; File "lt;frozen importlib._bootstrapgt;", line 1007, in _find_and_load File "lt;frozen importlib._bootstrapgt;", line 986, in _find_and_load_unlocked File "lt;frozen importlib._bootstrapgt;", line 680, in _load_unlocked File "PyInstaller/loader/pyimod03_importers.py", line 476, in exec_module File "mne/report/report.py", line 103, in lt;modulegt; File "pathlib.py", line 1266, in read_text File "pathlib.py", line 1252, in open File "pathlib.py", line 1120, in _opener FileNotFoundError: [Errno 2] No such file or directory: '/Users/fishbacp/python_files/dist/main_app.app/Contents/MacOS/mne/report/js_and_css/report.js'``` On my machine, the original version of report.js is located in ```/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/mne/report/js_and_css``` where ```mne``` is the signal analysis package, which I included as a hidden import. Is there a directory path I've misnamed above? (Python 3.9, Mac OS 11.6.1)