Error with opencv and libjpeg, using py2app

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error with opencv and libjpeg, using py2app

Oksana Meledin
I am trying to create a standalone Mac GUI app.

I used wxPython (wxpython-phoenix 4.0.0a4) to create the GUI.

I am trying to use py2app (0.14) to create a standalone app that can be used on a different machine not requiring a python installation.

Initially, I tried using anaconda python, but ran into grave difficulties. Now, I'm using homebrew python2.7.

The app runs fine on my local machine fine.

But on the target machine, I get the following error. "import cv2" is looking for libjpeg in a hardcoded location instead of inside the standalone Contents.
(There is a version of libjpeg inside: /repos/ct/dist/CtAnnotator.app/Contents/Frameworks/libjpeg.8.dylib.)


Traceback (most recent call last):
  File "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line 98, in <module>
    _run()
  File "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line 82, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/CtAnnotator.py", line 7, in <module>
    import cv2
ImportError: dlopen(/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/lib-dynload/cv2.so, 2): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
  Referenced from: /Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Frameworks/libopencv_highgui.2.4.13.dylib
  Reason: image not found

Does anyone have ideas on how to proceed?

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error with opencv and libjpeg, using py2app

Matt Newville


On Sat, Jul 15, 2017 at 6:48 PM, Oksana Meledin <[hidden email]> wrote:
I am trying to create a standalone Mac GUI app.

I used wxPython (wxpython-phoenix 4.0.0a4) to create the GUI.

I am trying to use py2app (0.14) to create a standalone app that can be used on a different machine not requiring a python installation.

Initially, I tried using anaconda python, but ran into grave difficulties. Now, I'm using homebrew python2.7.

The app runs fine on my local machine fine.

But on the target machine, I get the following error. "import cv2" is looking for libjpeg in a hardcoded location instead of inside the standalone Contents.
(There is a version of libjpeg inside: /repos/ct/dist/CtAnnotator.app/Contents/Frameworks/libjpeg.8.dylib.)


Traceback (most recent call last):
  File "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line 98, in <module>
    _run()
  File "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py", line 82, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/CtAnnotator.py", line 7, in <module>
    import cv2
ImportError: dlopen(/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/lib-dynload/cv2.so, 2): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
  Referenced from: /Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Frameworks/libopencv_highgui.2.4.13.dylib
  Reason: image not found

Does anyone have ideas on how to proceed?


You might be able to use `install_name_tool` to change where that opencv dynamic library is looking for libjpeg (and use `otool -L` to verify where it is actually looking before and after changing). 

I would guess that if you need to do it once, you may need to do it for another dozen or more cases.  You may also have to fiddle with the resulting app every time you build a new version. So I cannot say I recommend it, but it might work.

--Matt Newville

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error with opencv and libjpeg, using py2app

Igor Korot
Hi, Oksana,

On Sat, Jul 15, 2017 at 10:15 PM, Matt Newville
<[hidden email]> wrote:

>
>
> On Sat, Jul 15, 2017 at 6:48 PM, Oksana Meledin <[hidden email]>
> wrote:
>>
>> I am trying to create a standalone Mac GUI app.
>>
>> I used wxPython (wxpython-phoenix 4.0.0a4) to create the GUI.
>>
>> I am trying to use py2app (0.14) to create a standalone app that can be
>> used on a different machine not requiring a python installation.
>>
>> Initially, I tried using anaconda python, but ran into grave difficulties.
>> Now, I'm using homebrew python2.7.
>>
>> The app runs fine on my local machine fine.
>>
>> But on the target machine, I get the following error. "import cv2" is
>> looking for libjpeg in a hardcoded location instead of inside the standalone
>> Contents.
>> (There is a version of libjpeg inside:
>> /repos/ct/dist/CtAnnotator.app/Contents/Frameworks/libjpeg.8.dylib.)
>>
>>
>> Traceback (most recent call last):
>>   File
>> "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py",
>> line 98, in <module>
>>     _run()
>>   File
>> "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/__boot__.py",
>> line 82, in _run
>>     exec(compile(source, path, 'exec'), globals(), globals())
>>   File
>> "/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/CtAnnotator.py",
>> line 7, in <module>
>>     import cv2
>> ImportError:
>> dlopen(/Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Resources/lib/python2.7/lib-dynload/cv2.so,
>> 2): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.8.dylib
>>   Referenced from:
>> /Volumes/PciSsd/repos/ct/dist/CtAnnotator.app/Contents/Frameworks/libopencv_highgui.2.4.13.dylib
>>   Reason: image not found
>>
>> Does anyone have ideas on how to proceed?

Did you use wxPython binary from the official wxPython site or you
build it yourself?

Thank you.

>
>
>
> You might be able to use `install_name_tool` to change where that opencv
> dynamic library is looking for libjpeg (and use `otool -L` to verify where
> it is actually looking before and after changing).
>
> I would guess that if you need to do it once, you may need to do it for
> another dozen or more cases.  You may also have to fiddle with the resulting
> app every time you build a new version. So I cannot say I recommend it, but
> it might work.
>
> --Matt Newville
>
> --
> You received this message because you are subscribed to the Google Groups
> "wxPython-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error with opencv and libjpeg, using py2app

Courosh Mehanian
I downloaded the wheel from the wxpython.org: https://wxpython.org/Phoenix/snapshot-builds/.

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error with opencv and libjpeg, using py2app

Oksana Meledin
In reply to this post by Igor Korot
I downloaded the wheel from wxpython.org snapshot builds: https://wxpython.org/Phoenix/snapshot-builds/

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Error with opencv and libjpeg, using py2app

Chris Barker - NOAA Federal
In reply to this post by Courosh Mehanian
well, it's an opencv problem, so wx is probably unrelated.

py2app is _supposed_ to re-write the linking to fix this issue, so it may work to do it by hand for this one case -- hopefully the others did work right...

I'd post a question on the python-mac list:


very low traffic these days, but the primary py2app developer is on it.

You could also try PyInstaller -- it's working a bit better for us these days.

-CHB





On Sun, Jul 16, 2017 at 11:12 AM, Courosh Mehanian <[hidden email]> wrote:

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[hidden email]

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Loading...