在macOS中使用UPX减少可执行文件的大小

时间:2018-11-27 13:01:23

标签: python-3.x macos pyinstaller upx

我正在使用PyInstaller创建捆绑的应用程序。该应用程序包括numpy,因此捆绑应用程序的最终大小为> 600MB。我当然想压缩捆绑应用程序的大小,所以我通过brew install upx安装了upx。但是,PyInstaller崩溃并显示以下错误。

1- macOS可以使用UPX甚至PyIntaller吗?

2-我可以解决此错误吗?

3- PyInstaller在选定文件上创建捆绑的应用程序后,我可以手动运行UPX吗?如果可以,您能举一个UPX命令行示例吗?

错误:

Traceback (most recent call last):
  File "/Users/Kenny/miniconda3/envs/umsap/bin/pyinstaller", line 11, in <module>
    sys.exit(run())
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 838, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/build_main.py", line 784, in build
    exec(text, spec_namespace)
  File "<string>", line 47, in <module>
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/osx.py", line 89, in __init__
    self.__postinit__()
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/datastruct.py", line 158, in __postinit__
    self.assemble()
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/osx.py", line 169, in assemble
    fnm = checkCache(fnm, strip=self.strip, upx=self.upx, dist_nm=inm)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/building/utils.py", line 228, in checkCache
    dylib.mac_set_relative_dylib_deps(cachedfile, dist_nm)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/PyInstaller/depend/dylib.py", line 308, in mac_set_relative_dylib_deps
    dll = MachO(libname)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 95, in __init__
    self.load(fp)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 110, in load
    self.load_header(fh, 0, size)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 148, in load_header
    hdr = MachOHeader(self, fh, offset, size, magic, hdr, endian)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 188, in __init__
    self.load(fh)
  File "/Users/Kenny/miniconda3/envs/umsap/lib/python3.7/site-packages/macholib/MachO.py", line 293, in load
    read_bytes, header.sizeofcmds))
ValueError: Read 1592 bytes, header reports 1992 bytes

0 个答案:

没有答案