Manually specify library when pyinstaller sees conflicting versions

给你一囗甜甜゛ 提交于 2020-08-09 08:47:05

问题


Is it possible to manually replace or specify the location of a .dylib on Mac OSX when using pyinstaller?

I'm getting the error when trying to open my completed .app

Traceback (most recent call last):
  File "DeepMeerkat/main.py", line 3, in <module>
    import cv2
  File "/Library/Python/2.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 546, in load_module
    module = imp.load_module(fullname, fp, filename, ext_tuple)
ImportError: dlopen(/Users/ben/Documents/DeepMeerkat/Installer/dist/Lib/cv2.so, 2): Library not loaded: @loader_path/libpng16.16.dylib
  Referenced from: /Users/ben/Documents/DeepMeerkat/Installer/dist/Lib/libopencv_imgcodecs.3.3.dylib
  Reason: Incompatible library version: libopencv_imgcodecs.3.3.dylib requires version 48.0.0 or later, but libpng16.16.dylib provides version 45.0.0
Failed to execute script main

I have no problem loading cv2 in python outside of the app, or any other problems with open, which was installed with homebrew.

Poking around, I think it is extremely likely the error comes from pyinstaller grabbing libpng from X11 (/opt/X11/include/libpng16) when it needs to be grabbing from Homebrew's folders (/usr/local/Cellar/libpng/1.6.32/)

How can I use a hook to specify which libpng I want?


回答1:


I had the same problem, the answer lay in editing the .spec file. Add the following line after a = Analysis...:

a.binaries = a.binaries - TOC([('libpng16.16.dylib',None,None)])

This has the effect of removing the offending dylib from the relevant TOC file which solves the conflict.



来源:https://stackoverflow.com/questions/46246649/manually-specify-library-when-pyinstaller-sees-conflicting-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!