Last active
June 28, 2024 12:41
-
-
Save maxfil333/98a0ec7ea40599264a0c80f80ac026e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Получить .spec файл командой | |
pyinstaller --onefile src/main.py | |
2. Добавить в datas .spec файла пути | |
datas=[ | |
('C:\\Program Files\\poppler-22.01.0\\Library\\bin', 'poppler'), | |
('src', 'src'), | |
('config', 'config'), | |
('C:\\Program Files\\Tesseract-OCR', 'Tesseract-OCR'), | |
('C:\\Program Files\\ImageMagick-7.1.1-Q16-HDRI', 'magick') | |
], | |
3. Удалить dist, build | |
4. Собрать проект через pyinstaller main.spec | |
5. Варианты расположения и наличия директорий в сборке (на примере ImageMagick). | |
datas=[('C:\\Program Files\\ImageMagick-7.1.1-Q16-HDRI', 'magick')], | |
5.1 getattr(sys, 'frozen') + --onefile + --add-data/путь добавлен в .spec datas | |
os.path.join(sys._MEIPASS, 'magick', 'magick.exe') | |
5.2 getattr(sys, 'frozen') + --onefile - путь НЕ добавлен в .spec | |
Положить рядом с main.exe директорию с исполняемым файлом magick/magick.exe | |
os.path.join(os.path.dirname(sys.executable), 'magick', 'magick.exe') | |
5.3 getattr(sys, 'frozen') - --onefile - путь НЕ добавлен в .spec | |
Положить рядом с main.exe директорию с исполняемым файлом magick/magick.exe | |
os.path.join(os.path.dirname(sys.executable), 'magick', 'magick.exe') | |
5.4 getattr(sys, 'frozen') - --onefile + путь добавлен в .spec | |
os.path.join(sys._MEIPASS, 'magick', 'magick.exe') | |
5.5 Запуск из исходного кода | |
magick или C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment