#66986 closed defect (fixed)

py39-opencv4: Failure to load cv2 due to broken linking

Reported by: fmw42 (Fred Weinhaus) Owned by: stromnov (Andrey Stromnov)
Priority: Normal Milestone:
Component: ports Version: 2.8.1
Keywords: Cc: mascguy (Christopher Nielsen)
Port: opencv4

Description

I am on Mac OSX Monterey on M1 Mac (Mini)

I was trying to upgrade my existing ports that I have been using for quite a while.

I have done the sudo port selfupdate. Then upgraded most of my relevant ports. Then tried numerous times to upgrade either opencv4 or py39-opencv4. Other ports that try to upgrade opencv4 also report this error. I kept getting an error:

"Error: Failed to extract opencv4: extract.rename: multiple directories exist in /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_opencv4/opencv4/work: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_opencv4/opencv4/work/opencv-opencv-8a18519 /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_opencv4/opencv4/work/opencv-opencv_contrib-5f1f482
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_graphics_opencv4/opencv4/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there is a
bug."

I reported that error at https://trac.macports.org/ticket/66942

Now when I try use any of my existing OpenCV scripts it objects to importing cv2:

Traceback (most recent call last):
  File "/Users/fred/Desktop/tmp.py", line 1, in <module>
    import cv2
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/python-3.9/cv2.cpython-39-darwin.so, 0x0002): Library not loaded: '/opt/local/lib/libtiff.5.dylib'
  Referenced from: '/opt/local/lib/opencv4/libopencv_imgcodecs.4.6.0.dylib'
  Reason: tried: '/opt/local/lib/libtiff.5.dylib' (no such file), '/usr/local/lib/libtiff.5.dylib' (no such file), '/usr/lib/libtiff.5.dylib' (no such file)

I was told to report this as a separate ticket.

Change History (3)

comment:1 Changed 15 months ago by jmroot (Joshua Root)

Cc: stromnov mascguy@… removed
Owner: changed from stromnov@… to stromnov
Summary: Failure to load cv2py39-opencv4: Failure to load cv2 due to broken linking

Are you saying that you somehow found a way to upgrade opencv4 despite #66942, and are still getting this error, or that you have been unable to upgrade opencv4 and are getting this error? The latter would be "normal" given the inability to upgrade, since one of the recent updates was specifically to re-link with the new tiff version.

comment:2 Changed 15 months ago by fmw42 (Fred Weinhaus)

The latter -- I am unable to upgrade OpenCV4 and I believe this then led to the inability to import cv2. I posted this same error in my previous ticket, but was then told to post this as a separate ticket. What is the issue with TIFF. I successfully imported TIFF. So why is it complaining?

Last edited 15 months ago by fmw42 (Fred Weinhaus) (previous) (diff)

comment:3 Changed 15 months ago by jmroot (Joshua Root)

Resolution: fixed
Status: assignedclosed

OK, so once you upgrade this should be OK. Reopen if not.

Note: See TracTickets for help on using tickets.