Pyinstaller将我的应用程序编译成Windows上的.exe,但是我无法在Mac上构建一个有效的.app。我已经尝试过--onefile和--onedir,但没有骰子,应用程序只是打开然后立即关闭报告崩溃。它看起来像是模块导入问题,但我尝试通过pathex和datas中的.spec文件导入我知道的所有模块。我已经为发行版和开发版重新安装了pyinstaller。任何想法我还能尝试什么?谢谢!
SYSTEM: PyInstaller:3.3.1 Python:3.6.3 平台:Darwin-16.7.0-x86_64-i386-64bit
命令: pyinstaller --onedir --name = StaticBot --windowed StaticBot.spec
SPEC FILE:
# -*- mode: python -*-
import sys
sys.setrecursionlimit(5000)
block_cipher = None
a = Analysis(['../main.py'],
pathex=[
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/grid_objs',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/offline',
'/Users/justint/Documents/Justin/Dev/Staticbot'
],
binaries=[],
datas=[ ('../res_rc.py', '.'),
('../ui.py', '.'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/plotly/', './plotly/plotly/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/grid_objs/', './plotly/grid_objs/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/offline/', './plotly/offline/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/package_data/default-schema.json', './plotly/package_data/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/package_data/graphWidget.js', './plotly/package_data/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/package_data/plotly.min.js', './plotly/package_data/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil', './psutil')
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='Staticbot',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
icon='/Users/justint/Documents/Justin/Dev/Staticbot/_output_mac/Staticbot.icns',
console=False )
app = BUNDLE(exe,
name='Staticbot.app',
icon='/Users/justint/Documents/Justin/Dev/Staticbot/_output_mac/Staticbot.icns',
bundle_identifier=None)
警告列表:
missing module named pyimod03_importers - imported by /Library/Frameworks/Python.framework/Versions/3.6/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 netbios - imported by uuid
missing module named win32wnet - imported by uuid
missing module named __builtin__ - imported by numpy.core.numerictypes, numpy.core.numeric, numpy.distutils.misc_util, numpy.lib.function_base, numpy.lib._iotools, numpy.ma.core, numpy, pkg_resources._vendor.pyparsing
missing module named ordereddict - imported by pkg_resources._vendor.pyparsing
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 distutils.msvccompiler, pkg_resources._vendor.appdirs
missing module named 'win32com.shell' - imported by pkg_resources._vendor.appdirs
missing module named StringIO - imported by six, urllib3.packages.six, requests.compat, numpy.lib.utils, numpy.testing.nose_tools.utils, numpy.lib.format, pkg_resources._vendor.six
missing module named __main__ - imported by pkg_resources
missing module named multiprocessing.SimpleQueue - imported by multiprocessing, concurrent.futures.process
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.TimeoutError - imported by multiprocessing, multiprocessing.pool
missing module named multiprocessing.get_context - imported by multiprocessing, multiprocessing.pool, multiprocessing.managers, multiprocessing.sharedctypes
missing module named multiprocessing.BufferTooShort - imported by multiprocessing, multiprocessing.connection
missing module named multiprocessing.AuthenticationError - imported by multiprocessing, multiprocessing.connection
missing module named pkg_resources.extern.packaging - imported by pkg_resources.extern, pkg_resources, setuptools.dist, setuptools.command.egg_info
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 'multiprocessing.forking' - imported by /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/loader/rthooks/pyi_rth_multiprocessing.py
excluded module named _frozen_importlib - imported by importlib, importlib.abc, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named _frozen_importlib_external - imported by importlib._bootstrap, importlib, importlib.abc, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named _winreg - imported by platform, requests.utils, numpy.distutils.cpuinfo, /Users/justint/Documents/Justin/Dev/Staticbot/main.py, pkg_resources._vendor.appdirs
missing module named java - imported by platform, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named 'java.lang' - imported by platform, /Users/justint/Documents/Justin/Dev/Staticbot/main.py, xml.sax._exceptions
missing module named vms_lib - imported by platform, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named msvcrt - imported by subprocess, getpass, multiprocessing.spawn, multiprocessing.popen_spawn_win32, numpy.distutils.mingw32ccompiler, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named _winapi - imported by subprocess, multiprocessing.reduction, multiprocessing.connection, multiprocessing.heap, multiprocessing.popen_spawn_win32, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named winreg - imported by platform, mimetypes, urllib.request, requests.utils, distutils.msvccompiler, distutils.msvc9compiler, distutils._msvccompiler, numpy.distutils.cpuinfo, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named urllib.splittag - imported by urllib, setuptools.py26compat
missing module named urllib.getproxies_environment - imported by urllib, requests.compat
missing module named urllib.proxy_bypass_environment - imported by urllib, requests.compat
missing module named urllib.proxy_bypass - imported by urllib, requests.compat
missing module named urllib.getproxies - imported by urllib, requests.compat
missing module named urllib.urlencode - imported by urllib, requests.compat
missing module named urllib.unquote_plus - imported by urllib, requests.compat
missing module named urllib.quote_plus - imported by urllib, requests.compat
missing module named urllib.unquote - imported by urllib, requests.compat
missing module named urllib.quote - imported by urllib, requests.compat
missing module named _dummy_threading - imported by dummy_threading, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named nt - imported by os, ntpath, shutil, pathlib, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named 'org.python' - imported by copy, setuptools.sandbox, /Users/justint/Documents/Justin/Dev/Staticbot/main.py, xml.sax
missing module named org - imported by pickle, /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named Queue - imported by urllib3.connectionpool
missing module named "'urllib3.packages.six.moves.urllib'.parse" - imported by urllib3.request, urllib3.poolmanager
runtime module named urllib3.packages.six.moves - imported by http.client, urllib3.connectionpool, urllib3.util.response, 'urllib3.packages.six.moves.urllib', urllib3.response
missing module named backports - imported by urllib3.packages.ssl_match_hostname
missing module named socks - imported by urllib3.contrib.socks
missing module named 'OpenSSL.crypto' - imported by urllib3.contrib.pyopenssl
missing module named 'cryptography.x509' - imported by urllib3.contrib.pyopenssl
missing module named 'cryptography.hazmat' - imported by urllib3.contrib.pyopenssl
missing module named cryptography - imported by urllib3.contrib.pyopenssl
missing module named OpenSSL - imported by urllib3.contrib.pyopenssl
missing module named _abcoll - imported by urllib3.packages.ordered_dict
missing module named dummy_thread - imported by urllib3.packages.ordered_dict, numpy.core.arrayprint
missing module named thread - imported by urllib3.packages.ordered_dict, numpy.core.arrayprint
missing module named Cookie - imported by requests.compat
missing module named cookielib - imported by requests.compat
missing module named urllib2 - imported by requests.compat, setuptools.package_index, numpy.lib._datasource
missing module named urlparse - imported by requests.compat, numpy.lib._datasource
missing module named simplejson - imported by requests.compat
missing module named IPython - imported by plotly.plotly.plotly
runtime module named six.moves - imported by plotly.plotly.plotly, plotly.plotly.chunked_requests.chunked_request, 'six.moves.urllib'
missing module named "'six.moves.urllib'.parse" - imported by plotly.plotly.chunked_requests.chunked_request
missing module named pandas - imported by plotly.graph_objs.graph_objs, plotly.figure_factory._county_choropleth
missing module named numpy.lib.i0 - imported by numpy.lib, numpy.dual
missing module named numpy.linalg.inv - imported by numpy.linalg, numpy.matrixlib.defmatrix, numpy.lib.polynomial
missing module named cPickle - imported by numpy.core.numeric, numpy.lib.format, numpy.lib.npyio, numpy.ma.core
missing module named cStringIO - imported by cPickle
missing module named copy_reg - imported by cPickle, cStringIO, numpy.core
missing module named ConfigParser - imported by numpy.distutils.system_info, numpy.distutils.npy_pkg_config
missing module named 'numpy_distutils.cpuinfo' - imported by numpy.f2py.diagnose
missing module named 'numpy_distutils.fcompiler' - imported by numpy.f2py.diagnose
missing module named 'numpy_distutils.command' - imported by numpy.f2py.diagnose
missing module named numpy_distutils - imported by numpy.f2py.diagnose
missing module named numpy.testing.memusage - imported by numpy.testing, numpy.f2py.f2py_testing
missing module named numpy.testing.jiffies - imported by numpy.testing, numpy.f2py.f2py_testing
missing module named setuptools_svn - imported by setuptools.command.egg_info
missing module named 'setuptools.extern.six' - imported by setuptools, setuptools.extension
missing module named wincertstore - imported by setuptools.ssl_support
missing module named 'backports.ssl_match_hostname' - imported by setuptools.ssl_support
missing module named win32com - imported by setuptools.sandbox
missing module named 'pkg_resources.extern.packaging.version' - imported by setuptools.msvc
missing module named 'setuptools.extern.six.moves' - imported by setuptools.dist, setuptools.command.easy_install, setuptools.sandbox, setuptools.command.setopt, setuptools.package_index, setuptools.ssl_support, setuptools.command.egg_info, setuptools.command.py36compat, setuptools.msvc
missing module named setuptools.extern.six - imported by setuptools.extern, setuptools.monkey, setuptools.dist, setuptools.depends, setuptools.command.easy_install, setuptools.sandbox, setuptools.package_index, setuptools.command.bdist_egg, setuptools.command.egg_info, setuptools.command.sdist, setuptools.unicode_utils, setuptools.glob, setuptools.command.develop
missing module named _findvs - imported by distutils._msvccompiler
missing module named __svn_version__ - imported by numpy.f2py.__version__
missing module named numarray - imported by numpy.distutils.system_info
missing module named Numeric - imported by numpy.distutils.system_info
missing module named commands - imported by numpy.distutils.cpuinfo
missing module named 'nose.plugins' - imported by numpy.testing.nose_tools.noseclasses, numpy.testing.nose_tools.nosetester
missing module named scipy - imported by numpy.testing.nose_tools.nosetester
missing module named 'nose.util' - imported by numpy.testing.nose_tools.noseclasses
missing module named nose - imported by numpy.testing.nose_tools.utils, numpy.testing.nose_tools.decorators, numpy.testing.nose_tools.noseclasses
missing module named numpy.core.number - imported by numpy.core, numpy.testing.nose_tools.utils
missing module named numpy.lib.imag - imported by numpy.lib, numpy.testing.nose_tools.utils
missing module named numpy.lib.real - imported by numpy.lib, numpy.testing.nose_tools.utils
missing module named numpy.lib.iscomplexobj - imported by numpy.lib, numpy.testing.nose_tools.utils
missing module named numpy.core.signbit - imported by numpy.core, numpy.testing.nose_tools.utils
missing module named win32pdh - imported by numpy.testing.nose_tools.utils
missing module named numpy.core.float64 - imported by numpy.core, numpy.testing.nose_tools.utils
missing module named numpy.core.float32 - imported by numpy.core, numpy.testing.nose_tools.utils
missing module named win32con - imported by distutils.msvccompiler
missing module named numpy.core.integer - imported by numpy.core, numpy.fft.helper
missing module named numpy.core.sqrt - imported by numpy.core, numpy.linalg.linalg, numpy.fft.fftpack
missing module named numpy.core.conjugate - imported by numpy.core, numpy.fft.fftpack
missing module named numpy.lib.triu - imported by numpy.lib, numpy.linalg.linalg
missing module named numpy.core.divide - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.object_ - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.intp - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.longdouble - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.geterrobj - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.maximum - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.add - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.complexfloating - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.inexact - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.cdouble - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.csingle - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.double - imported by numpy.core, numpy.linalg.linalg
missing module named numpy.core.single - imported by numpy.core, numpy.linalg.linalg
missing module named future_builtins - imported by numpy.lib.npyio
missing module named numpy.recarray - imported by numpy, numpy.ma.mrecords
missing module named numpy.dtype - imported by numpy, numpy.ma.mrecords, numpy.ctypeslib
missing module named numpy.expand_dims - imported by numpy, numpy.ma.core
missing module named numpy.array - imported by numpy, numpy.ma.core, numpy.ma.extras, numpy.ma.mrecords, numpy.ctypeslib
missing module named numpy.bool_ - imported by numpy, numpy.ma.core, numpy.ma.mrecords
missing module named numpy.iscomplexobj - imported by numpy, numpy.ma.core
missing module named numpy.amin - imported by numpy, numpy.ma.core
missing module named numpy.amax - imported by numpy, numpy.ma.core
missing module named numpy.ndarray - imported by numpy, numpy.ma.core, numpy.ma.extras, numpy.ma.mrecords, numpy.ctypeslib
missing module named numpy.histogramdd - imported by numpy, numpy.lib.twodim_base
missing module named numpy.eye - imported by numpy, numpy.core.numeric
missing module named sets - imported by pytz.tzinfo
missing module named UserDict - imported by pytz.lazy
missing module named psutil._psutil_aix - imported by psutil, psutil._psaix
missing module named psutil._psutil_sunos - imported by psutil, psutil._pssunos
missing module named psutil._psutil_bsd - imported by psutil, psutil._psbsd
missing module named psutil._psutil_windows - imported by psutil, psutil._pswindows
missing module named _psutil_linux - imported by psutil
missing module named win32process - imported by /Users/justint/Documents/Justin/Dev/Staticbot/main.py
missing module named win32gui - imported by /Users/justint/Documents/Justin/Dev/Staticbot/main.py
答案 0 :(得分:0)
确定.app没有运行的原因有点困难,但可能是由于你建议缺少模块。通过从终端运行.app(而不是双击可执行文件),您可以更轻松地查看与过早关闭应用程序相关的错误消息:
/path/to/app/dist/MyApp.app/Contents/MacOS/MyApp
如果这报告了您无法调试的错误,请将其作为编辑添加到您的问题中。
如果程序因导入模块失败而失败,您可以将模块添加到.spec文件中的hiddenimports列表中,然后再次运行PyInstaller(pyinstaller myfile.spec
)。或者您可以将以下选项添加到PyInstaller命令中:
pyinstaller [options] --hiddenimport=missing_module myfile.py
我不认为通过pathex或数据列表导入模块是明确添加它们的推荐方法。
答案 1 :(得分:0)
修正了它。看起来该解决方案是使用--onedir而不是--onefile并切换回最新版本的PyInstaller而不是dev pyqt5-fix版本,并将org.qt-project.Qt.QtWebEngineCore设置为bundle_identifier。除了PyQt5之外,还要确保安装了Qt5。
<强>命令强>
pyinstaller --onefile --name=Staticbot --windowed Staticbot.spec
<强>要求强>
系统
的Python
规范文件
block_cipher = None
a = Analysis(['../main.py'],
pathex=[
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/grid_objs',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/offline',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5',
'/Users/justint/Documents/Justin/Dev/Staticbot'
],
binaries=[],
datas=[('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/plotly/', './plotly/plotly/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/grid_objs/', './plotly/grid_objs/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/offline/', './plotly/offline/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/package_data/default-schema.json', './plotly/package_data/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/package_data/graphWidget.js', './plotly/package_data/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/plotly/package_data/plotly.min.js', './plotly/package_data/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/QtWebEngine.so', './PyQt5/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/QtWebEngineCore.so', './PyQt5/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/QtWebEngineWidgets.so', './PyQt5/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyQt5/Qt/lib/QtWebEngineCore.framework/Helpers/QtWebEngineProcess.app', './PyQt5/Qt/lib/QtWebEngineCore.framework/Helpers/'),
('/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/psutil', './psutil')
],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='Staticbot',
debug=False,
strip=False,
upx=False,
console=False )
coll = COLLECT( exe,
a.binaries,
a.scripts,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name='Staticbot')
app = BUNDLE(coll,
name='Staticbot.app',
bundle_identifier='org.qt-project.Qt.QtWebEngineCore')