pyinstaller not working with gphoto2; how do i force a brew library into the build

29 views
Skip to first unread message

Craigs List

unread,
Apr 3, 2020, 3:19:09 AM4/3/20
to PyInstaller
I'm attempting to build a project with gphoto2.  gphoto2 requires brew install libgphoto2.

The binary is created successfully, but when I run the binary on a machine that doesn't have libgphoto2, it fails.  once i brew install the package is continues to work.

help?

Abasi Brown

unread,
Apr 3, 2020, 9:07:02 AM4/3/20
to pyins...@googlegroups.com
1. Try opening the spec file and after the line that says 'block_cipher = None' put:

def get_gphoto2_path():
     import gphoto2
     gphoto2_path = gphoto2.__path__[0]
     return gphoto2_path

2. Then after the lines that say 'pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)' put:

dict_tree = Tree(get_gphoto2_path(), prefix='gphoto2', excludes=["*.pyc"])
a.datas += dict_tree
a.binaries = filter(lambda x: 'gphoto2' not in x[0], a.binaries)

3. Then go to your command line and run the following command:

pyinstaller your_file_name.spec --specpath=test

Then run the executable.

--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/bd4a338a-1941-48dc-870f-36d4a2b1a57f%40googlegroups.com.

Abasi Brown

unread,
Apr 3, 2020, 9:10:09 AM4/3/20
to pyins...@googlegroups.com
1. Try opening the spec file and after the line that says 'block_cipher = None' put:

def get_libgphoto2_path():
     import libgphoto2
     libgphoto2_path = libgphoto2.__path__[0]
     return libgphoto2_path

2. Then after the lines that say 'pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)' put:

dict_tree = Tree(get_libgphoto2_path(), prefix='libgphoto2', excludes=["*.pyc"])
a.datas += dict_tree
a.binaries = filter(lambda x: 'libgphoto2' not in x[0], a.binaries)

3. Then go to your command line and run the following command:

pyinstaller your_file_name.spec --specpath=test

Then run the executable.

Craigs List

unread,
Apr 3, 2020, 3:33:35 PM4/3/20
to PyInstaller

It seems to have progressed into another problem:

Traceback (most recent call last):

  File "gphoto2/widget.py", line 25, in swig_import_helper

  File "importlib/__init__.py", line 127, in import_module

  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import

  File "<frozen importlib._bootstrap>", line 983, in _find_and_load

  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked

  File "<frozen importlib._bootstrap>", line 670, in _load_unlocked

  File "<frozen importlib._bootstrap>", line 583, in module_from_spec

  File "<frozen importlib._bootstrap_external>", line 1043, in create_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

ImportError: dlopen(/var/folders/fz/355jj9z51c9b8s7q5r90k8100000gn/T/_MEI04FTXC/_widget.cpython-37m-darwin.so, 2): Library not loaded: @loader_path/libgphoto2.6.dylib

  Referenced from: /var/folders/fz/355jj9z51c9b8s7q5r90k8100000gn/T/_MEI04FTXC/_widget.cpython-37m-darwin.so

  Reason: image not found

Craigs List

unread,
Apr 3, 2020, 3:33:43 PM4/3/20
to PyInstaller
Also, libgphoto is a collection of dylib


On Friday, April 3, 2020 at 12:19:09 AM UTC-7, Craigs List wrote:
Reply all
Reply to author
Forward
0 new messages