Pyinstaller 3.3.1 и 3.4.0-dev, сборка с помощью apscheduler
Приветствие!
Я пытаюсь сделать сборку с помощью PyInstaller. Config: Python 3.6.5
pip 10.0.1
, ОПЕРАЦИОННЫЕ СИСТЕМЫ: Ubuntu 18.04
, С помощью virtualenv
(также пробовал с python -m venv
).
Мое приложение использует apscheduler
, websocket
, _thread
и похоже, что некоторые связанные модули имеют проблемы с импортом. Пытался pyinstaller --onefile mymain.spec
& pyinstaller --onedir mymain.spec
, Проблема сохраняется в обоих случаях. Программа работает без ошибок, если не заморожена.
вот ошибка, которую я получаю, если я пытаюсь запустить сгенерированный исполняемый файл:
Traceback (most recent call last):
File "apscheduler/schedulers/base.py", line 882, in _create_plugin_instance
KeyError: 'interval'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "cmonitorcli/services/socket_client.py", line 70, in run
File "cmonitorcli/services/scheduler.py", line 36, in add_update_job
File "apscheduler/schedulers/base.py", line 413, in add_job
File "apscheduler/schedulers/base.py", line 907, in _create_trigger
File "apscheduler/schedulers/base.py", line 890, in _create_plugin_instance
LookupError: No trigger by the name "interval" was found
^CTraceback (most recent call last):
File "websocket/_app.py", line 283, in run_forever
File "websocket/_app.py", line 50, in read
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "cmonitorcli/main.py", line 20, in <module>
File "cmonitorcli/main.py", line 8, in main_job
File "cmonitorcli/client.py", line 29, in __init__
File "cmonitorcli/services/socket_client.py", line 31, in connect
File "websocket/_app.py", line 283, in run_forever
KeyboardInterrupt
Модули импорта предупреждений:
missing module named 'multiprocessing.forking' - imported by /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/venv/lib/python3.6/site-packages/PyInstaller/loader/rthooks/pyi_rth_multiprocessing.py
missing module named multiprocessing.get_context - imported by multiprocessing, multiprocessing.pool, multiprocessing.managers, multiprocessing.sharedctypes
missing module named multiprocessing.TimeoutError - imported by multiprocessing, multiprocessing.pool
missing module named multiprocessing.BufferTooShort - imported by multiprocessing, multiprocessing.connection
missing module named multiprocessing.AuthenticationError - imported by multiprocessing, multiprocessing.connection
missing module named multiprocessing.set_start_method - imported by multiprocessing, multiprocessing.spawn
missing module named multiprocessing.get_start_method - imported by multiprocessing, multiprocessing.spawn
missing module named multiprocessing.SimpleQueue - imported by multiprocessing, concurrent.futures.process
missing module named pyimod03_importers - imported by /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/venv/lib/python3.6/site-packages/PyInstaller/loader/rthooks/pyi_rth_pkgres.py
missing module named 'pkg_resources.extern.pyparsing' - imported by pkg_resources._vendor.packaging.requirements, pkg_resources._vendor.packaging.markers
missing module named StringIO - imported by six, pkg_resources._vendor.six
missing module named 'win32com.shell' - imported by pkg_resources._vendor.appdirs
missing module named 'com.sun' - imported by pkg_resources._vendor.appdirs
missing module named com - imported by pkg_resources._vendor.appdirs
missing module named win32api - imported by pkg_resources._vendor.appdirs
missing module named win32com - imported by pkg_resources._vendor.appdirs
missing module named 'ctypes.macholib' - imported by ctypes.util
missing module named netbios - imported by uuid
missing module named win32wnet - imported by uuid
missing module named __builtin__ - imported by pkg_resources._vendor.pyparsing
missing module named ordereddict - imported by pkg_resources._vendor.pyparsing
missing module named __main__ - imported by pkg_resources
missing module named pkg_resources.extern.packaging - imported by pkg_resources.extern, pkg_resources
missing module named pkg_resources.extern.appdirs - imported by pkg_resources.extern, pkg_resources
missing module named 'pkg_resources.extern.six.moves' - imported by pkg_resources, pkg_resources._vendor.packaging.requirements
missing module named pkg_resources.extern.six - imported by pkg_resources.extern, pkg_resources
missing module named nt - imported by os, shutil, ntpath, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
missing module named org - imported by pickle, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
excluded module named _frozen_importlib - imported by importlib, importlib.abc, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
missing module named _winreg - imported by platform, tzlocal.win32, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py, pkg_resources._vendor.appdirs
missing module named _scproxy - imported by urllib.request
missing module named java - imported by platform, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
missing module named 'java.lang' - imported by platform, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py, xml.sax._exceptions
missing module named vms_lib - imported by platform, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
missing module named winreg - imported by platform, mimetypes, tzlocal.win32, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py, urllib.request
missing module named msvcrt - imported by subprocess, multiprocessing.spawn, multiprocessing.popen_spawn_win32, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py, getpass
missing module named _winapi - imported by subprocess, multiprocessing.reduction, multiprocessing.connection, multiprocessing.heap, multiprocessing.popen_spawn_win32, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
missing module named _dummy_threading - imported by dummy_threading, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py
missing module named 'org.python' - imported by copy, /home/hoop/PycharmProjects/cmonitorserv/cmonitorcli/main.py, xml.sax
missing module named funcsigs - imported by apscheduler.util
missing module named sets - imported by pytz.tzinfo
missing module named UserDict - imported by pytz.lazy
missing module named wsaccel - imported by websocket._utils
missing module named backports - imported by websocket._ssl_compat
missing module named socks - imported by websocket._http
missing module named "'six.moves.urllib'.parse" - imported by websocket._url
missing module named Cookie - imported by websocket._cookiejar
missing module named 'wsaccel.xormask' - imported by websocket._abnf
missing module named numpy - imported by websocket._abnf
missing module named win32evtlog - imported by logging.handlers
missing module named win32evtlogutil - imported by logging.handlers
needs.txt:
jsonpickle==0.9.6
pkg-resources==0.0.0
six==1.11.0
websocket-client==0.48.0
apscheduler==3.5.1
pyinstaller==3.3.1
мне нужно сделать --onefile
строить.
Обратите внимание, например, используя hiddenimports
с этими:
missing module named 'wsaccel.xormask' - imported by websocket._abnf
missing module named numpy - imported by websocket._abnf
missing module named win32evtlog - imported by logging.handlers
и любые другие модули не помогают - они все еще появляются в журнале с missing module
флаг
3 ответа
На основе Alex Grönholm
Ответить:
Проблема действительно была в том, что APScheduler
используя setuptools
точки входа для поиска классов триггера.
Решение состоит в том, чтобы создать триггер и перейти к add_job()
:
from apscheduler.schedulers.background import BackgroundScheduler
from apscheduler.triggers import interval
scheduler = BackgroundScheduler()
trigger = interval.IntervalTrigger(seconds=3)
scheduler.add_job(lambda: job_func(ws), trigger=trigger, id='status_update_job', replace_existing=True)
Проблема заключается в том, что pyinstaller не упаковывает точки входа setuptools, которые требуются APScheduler для поиска классов триггеров. Обходной путь - импортировать и использовать триггеры вручную.
pyinstaller - один файл. После этого - заглянуть в.spec. Все недостающие модули добавляются вручную. В Pyinstaller есть ошибка с этой "спецификацией автоконфигурации"