Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

symbol not found: __ZTINIlmThread_3_14TaskE on Macos 11.7.7 #24

Open
EmberLightVFX opened this issue Jun 13, 2023 · 30 comments
Open

symbol not found: __ZTINIlmThread_3_14TaskE on Macos 11.7.7 #24

EmberLightVFX opened this issue Jun 13, 2023 · 30 comments

Comments

@EmberLightVFX
Copy link

EmberLightVFX commented Jun 13, 2023

I'm trying to run a python script running pip-openexr 1.3.9.
On windows there are no problems but on mac I'm getting this error from the import:

ImportError: dlopen([...].env/lib/python3.9/site-packages/OpenEXR.cpython-39-darwin.so, 2): Symbol not found: __ZTINIlmThread_3_14TaskE
Expected in: flat enamespace

I'm runnin macos 11.7.7 and python 3.9.13

Any idea why this is happening? A bad wheel?

@EmberLightVFX EmberLightVFX changed the title sumbol not found: __ZTINIlmThread_3_14TaskE on Macos symbol not found: __ZTINIlmThread_3_14TaskE on Macos 11.7.7 Jun 13, 2023
@sanguinariojoe
Copy link
Owner

I suppose it is missing a -lm link. I do not understand why though... I suppose that is a dependency of OpenEXR or Imath and for some reason it was dinamically linked.

@sanguinariojoe
Copy link
Owner

Perhaps you have not installed pthreads or mthreads?

@EmberLightVFX
Copy link
Author

EmberLightVFX commented Jun 13, 2023

I haven't installed pthreads or mthreads. Would it be some kind of c package?
So even tho there is a darwin-wheel now I still need to compile OpenEXR for mac? The windows wheel works flawless. I haven't tried on Linux yet.

@sanguinariojoe
Copy link
Owner

I found this:

luarocks/luarocks#1380

I would say pthreads should be somewhere. The problem is that I do not have a MacOS to dive into this problem. Maybe I will enable the tests on MacOS autobuilds too, but I think that would not help at all

@EmberLightVFX
Copy link
Author

Yeah I'm using Big Sur so it might be something to do with that
But does that mean that everyone that wants to use your wheels in Bug Sur+ need to manually install pthreads?
Are you running luarocks 3.9.0+ when you created the wheels?
Would you mind sharing your macos build setup for the wheels?

@sanguinariojoe
Copy link
Owner

But does that mean that everyone that wants to use your wheels in Bug Sur+ need to manually install pthreads?

No idea. It is what we are trying to figure out here.

Are you running luarocks 3.9.0+ when you created the wheels?

Nope, they are just having similar issues, so we might try to learn from them

Would you mind sharing your macos build setup for the wheels?

You can check how is the wheel built on MacOS here (actually for all platforms):
https://github.com/sanguinariojoe/pip-openexr/blob/main/.github/workflows/autobuild.yml

The idea is:

  1. I clone this repository somewhere
  2. I change the setup.py by the one prepared for statically linking everything (https://github.com/sanguinariojoe/pip-openexr/blob/main/.github/workflows/autobuild.yml#L89)
  3. I download ZLib, IMath and OpenEXR in the subfolders zlib, imath and openexr. I have also the empty subfolders zlib.build, imath.build, openexr.build and openexr.install to compile and install them
  4. I compile and install ZLib, IMath and OpenEXR with the commands on https://github.com/sanguinariojoe/pip-openexr/blob/main/.github/workflows/autobuild.yml#L58
  5. And then you can use the setup.py. On the GitHub actions I am using cibuildwheel to create all the wheels for all the platforms, but you can use it to install it directly, python setup.py install

@TobiasNoell
Copy link

I am having the same issue under Ubuntu (18.04).
import OpenEXR ImportError: /usr/local/lib/python3.9/site-packages/OpenEXR.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZTIN13IlmThread_3_14TaskE

Under Windows, everything is working as expected.

Strangely, OpenEXR==1.3.8 is working successfully under Ubuntu.

@sanguinariojoe
Copy link
Owner

With Ubuntu I can work! can you @TobiasNoell please check your Python version and download the appropriate wheel from here?

e.g. if you use Python 3.8 please download the wheel named OpenEXR-1.3.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Then uncompress it and go into the folder, then type:

ldd OpenEXR.cpython-38-x86_64-linux-gnu.so

(The name of the file would change depending on the specific wheel) and paste here the result

@sanguinariojoe
Copy link
Owner

Meanwhile I am probably disabling threading on OpenEXR

@sanguinariojoe
Copy link
Owner

Apparently OpenEXR won't compile with the option OPENEXR_ENABLE_THREADING=OFF, neither on windows nor on MacOS

@sanguinariojoe
Copy link
Owner

I submitted an issue

@TobiasNoell
Copy link

Thanks for the step-by-step instruction. Was really helpful :)

The output of what you requested is:

2023-06-15 13:00:32     linux-vdso.so.1 (0x00007fff3d3b7000)
2023-06-15 13:00:32     libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb9b6d58000)
2023-06-15 13:00:32     libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb9b69ba000)
2023-06-15 13:00:32     libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb9b67a2000)
2023-06-15 13:00:32     libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb9b6583000)
2023-06-15 13:00:32     libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb9b6192000)
2023-06-15 13:00:32     /lib64/ld-linux-x86-64.so.2 (0x00007fb9b7437000)

@sanguinariojoe
Copy link
Owner

It should be working! Look:

2023-06-15 13:00:32 libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb9b6583000)

Weiiird... I need to give this a second thought...

@EmberLightVFX
Copy link
Author

EmberLightVFX commented Jun 15, 2023

I tried to do some research myself but the only thing I came across was this: AcademySoftwareFoundation/openexr#1449 but that's for macos <= 10.8 and not 10.9 that Github Actions seeems to compile with.
Any how, I tried to git clone the openexr repo instead of downloading the latest release to get the fix but I'm now stuck at this error:

     g++ -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.6/OpenEXR.o -o build/lib.macosx-10.9-x86_64-3.6/OpenEXR.cpython-36m-darwin.so ./openexr.install/lib/libz.a ./openexr.install/lib/libIex-3_1.a ./openexr.install/lib/libOpenEXR-3_1.a
    clang: error: no such file or directory: './openexr.install/lib/libIex-3_1.a'
    clang: error: no such file or directory: './openexr.install/lib/libOpenEXR-3_1.a'
    error: command 'g++' failed with exit status 1

The change I did to the workflow is:

      #- name: download OpenEXR source code
      #  uses: suisei-cn/[email protected]
      #  with:
      #    url: https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v3.1.8.tar.gz
      #    target: ${{github.workspace}}/
      #
      #- name: Extract OpenEXR
      #  run: |
      #      tar -xvzf v3.1.8.tar.gz -C ${{github.workspace}}/
      #      mv openexr-3.1.8 openexr
      #      rm v3.1.8.tar.gz
      - name: Create openexr directory
        run: mkdir ${{github.workspace}}/openexr

      - name: Download OpenEXR repository
        run: git clone https://github.com/AcademySoftwareFoundation/openexr.git ${{github.workspace}}/openexr

Here is the log: https://pipelines.actions.githubusercontent.com/serviceHosts/10a60e38-0b02-49a8-832b-6610095aac9f/_apis/pipelines/1/runs/19/signedlogcontent/12?urlExpires=2023-06-15T15%3A04%3A15.0791247Z&urlSigningMethod=HMACV1&urlSignature=Mvqaie0MgdTFaZiuoeKfK45Yhnc92ndZovfKvf5MDK0%3D

@EmberLightVFX
Copy link
Author

ASF seems to fix the problem in this PR: AcademySoftwareFoundation/openexr#1462
Hopefully this will solve this problem :)

Bonus question: What does the pthreads actually do?

@TobiasNoell
Copy link

Cool! Just to understand, this is fixing that OpenEXR can be compiled without threading? And this would then most likely remove the linker error? The downside would probably be that the performance would be decreased?

@EmberLightVFX
Copy link
Author

It should fix so it can be compiled without threading. They have fixed some importing issue so maybe compiling with threading will fix the linker error... No idea but might be worth testing

@sanguinariojoe
Copy link
Owner

This week I am on a congress, but I will try to tackle this ASAP

@yellowtailfan
Copy link

yellowtailfan commented Jun 30, 2023

I had the same runtime link error during OpenEXR import in Python after building a Docker container that uses pyexr which depends on Python package openexr and was picking up openexr 1.3.9. I worked around it by installing Python package openexr 1.3.8:

$ pip3 install OpenEXR==1.3.8

Diagnosis

Confusingly, my local system is importing fine using the same version of the openexr Python package (1.3.9) but the library file inside has a different MD5 checksum. It looks like the 1.3.9 wheels have been updated about a month ago, well after the original release of 1.3.9 last year. The Docker build is picking up the new version with the issue, while my local system still has the older version.

The updated versions seem to have broken the linking with the ILM libraries, specifically with ImThread.

Inside container with broken Python openexr package (tried with both python:3.10 and ubuntu:22.04):

$ ldd ~/.local/lib/python3.10/site-packages/OpenEXR.cpython-310-x86_64-linux-gnu.so
        linux-vdso.so.1 (0x00007ffcdaac9000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f001ba23000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f001b93c000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f001b91c000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f001b917000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f001b6ef000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f001bfaa000)

$ md5sum ~/.local/lib/python3.10/site-packages/OpenEXR.cpython-310-x86_64-linux-gnu.so
a118edd77239a29950a3993af7c85438  ~/.local/lib/python3.10/site-packages/OpenEXR.cpython-310-x86_64-linux-gnu.so

Import fails with:

File "/home/[user]/.local/lib/python3.10/site-packages/pyexr/exr.py", line 6, in <module>
    import OpenEXR, Imath
ImportError: /home/[user]/.local/lib/python3.10/site-packages/OpenEXR.cpython-310-x86_64-linux-gnu.so: undefined symbol: _ZTIN13IlmThread_3_14TaskE

Inside my local Linux (Windows 11 WSL2 Ubuntu 22.04):

$ ldd ~/.local/lib/python3.10/site-packages/OpenEXR.cpython-310-x86_64-linux-gnu.so
        linux-vdso.so.1 (0x00007fff4d3b7000)
        libIex-2_5.so.25 => /lib/x86_64-linux-gnu/libIex-2_5.so.25 (0x00007fb69df2a000)
        libIlmImf-2_5.so.25 => /lib/x86_64-linux-gnu/libIlmImf-2_5.so.25 (0x00007fb69dc57000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb69da2b000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb69da0b000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb69d7e3000)
        libImath-2_5.so.25 => /lib/x86_64-linux-gnu/libImath-2_5.so.25 (0x00007fb69d7c9000)
        libIlmThread-2_5.so.25 => /lib/x86_64-linux-gnu/libIlmThread-2_5.so.25 (0x00007fb69d7bf000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fb69d7a3000)
        libHalf-2_5.so.25 => /lib/x86_64-linux-gnu/libHalf-2_5.so.25 (0x00007fb69d75e000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb69d677000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fb69dfc5000)
$ md5sum .local/lib/python3.10/site-packages/OpenEXR.cpython-310-x86_64-linux-gnu.so
5ae7a62111816186cad8587827fecb38  .local/lib/python3.10/site-packages/OpenEXR.cpython-310-x86_64-linux-gnu.so

Import succeeds.

I have libopenexr-dev installed via apt on both my local system and inside the container.

I saw in some other issue comments here that @sanguinariojoe has released new builds with static linking of the OpenEXR libraries. Is it possible that this change has somehow broken the library linkages on at least on some systems?

@geoffreymantel
Copy link

I have two different builds of a Docker image, each with OpenEXR 1.3.9 installed, but clearly a different build. It seems that it was rev'd without a version change.

Working build, built May 20 2023 -- no missing symbol:

> pip show -f OpenEXR
Name: OpenEXR
Version: 1.3.9
Summary: Python bindings for ILM's OpenEXR image file format
Home-page: https://github.com/sanguinariojoe/pip-openexr
Author: James Bowman
Author-email: [email protected]
License: UNKNOWN
Location: /opt/venv/lib/python3.8/site-packages
Requires: 
Required-by: PyEXR, avro-utils
Files:
  Imath.py
  OpenEXR-1.3.9.egg-info/PKG-INFO
  OpenEXR-1.3.9.egg-info/SOURCES.txt
  OpenEXR-1.3.9.egg-info/dependency_links.txt
  OpenEXR-1.3.9.egg-info/top_level.txt
  OpenEXR.cpython-38-x86_64-linux-gnu.so
  __pycache__/Imath.cpython-38.pyc

> ll /opt/venv/lib/python3.8/site-packages/OpenEXR.cpython-38-x86_64-linux-gnu.so
-rwxr-xr-x 1 root root 862984 May 20 23:36 /opt/venv/lib/python3.8/site-packages/OpenEXR.cpython-38-x86_64-linux-gnu.so*

> ldd /opt/venv/lib/python3.8/site-packages/OpenEXR.cpython-38-x86_64-linux-gnu.so
	linux-vdso.so.1 (0x00007fff2d76f000)
	libIex-2_3.so.24 => /usr/lib/x86_64-linux-gnu/libIex-2_3.so.24 (0x00007f5037d39000)
	libIlmImf-2_3.so.24 => /usr/lib/x86_64-linux-gnu/libIlmImf-2_3.so.24 (0x00007f5037a5a000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5037878000)
	libgcc_s.so.1 => /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f503785d000)
	libc.so.6 => /usr/lib/x86_64-linux-gnu/libc.so.6 (0x00007f503766b000)
	libpthread.so.0 => /usr/lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5037648000)
	libz.so.1 => /usr/lib/x86_64-linux-gnu/libz.so.1 (0x00007f503762a000)
	libHalf.so.24 => /usr/lib/x86_64-linux-gnu/libHalf.so.24 (0x00007f50375e5000)
	libIlmThread-2_3.so.24 => /usr/lib/x86_64-linux-gnu/libIlmThread-2_3.so.24 (0x00007f50375db000)
	libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6 (0x00007f503748c000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f5037d88000)

And the broken image, built today, missing symbol:

> pip show -f OpenEXR
Name: OpenEXR
Version: 1.3.9
Summary: Python bindings for ILM's OpenEXR image file format
Home-page: https://github.com/sanguinariojoe/pip-openexr
Author: James Bowman
Author-email: [email protected]
License: None
Location: /opt/venv/lib/python3.8/site-packages
Requires: 
Required-by: PyEXR, avro-utils
Files:
  Imath.py
  OpenEXR-1.3.9.dist-info/INSTALLER
  OpenEXR-1.3.9.dist-info/LICENSE
  OpenEXR-1.3.9.dist-info/METADATA
  OpenEXR-1.3.9.dist-info/RECORD
  OpenEXR-1.3.9.dist-info/WHEEL
  OpenEXR-1.3.9.dist-info/top_level.txt
  OpenEXR.cpython-38-x86_64-linux-gnu.so
  __pycache__/Imath.cpython-38.pyc

> ll /opt/venv/lib/python3.8/site-packages/OpenEXR.cpython-38-x86_64-linux-gnu.so
-rwxr-xr-x 1 root root 4590176 Jul  8 21:06 /opt/venv/lib/python3.8/site-packages/OpenEXR.cpython-38-x86_64-linux-gnu.so*

> ldd /opt/venv/lib/python3.8/site-packages/OpenEXR.cpython-38-x86_64-linux-gnu.so
	linux-vdso.so.1 (0x00007fff7d3d3000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd85ac0c000)
	libm.so.6 => /usr/lib/x86_64-linux-gnu/libm.so.6 (0x00007fd85aabd000)
	libgcc_s.so.1 => /usr/lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd85aaa2000)
	libpthread.so.0 => /usr/lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fd85aa7f000)
	libc.so.6 => /usr/lib/x86_64-linux-gnu/libc.so.6 (0x00007fd85a88d000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fd85b157000)

@sanguinariojoe
Copy link
Owner

Ok guys! I am integrating into OpenEXR. See #11 and AcademySoftwareFoundation/openexr#1487.

On that PR the Python wheels are fixed and working on all platforms

@SlimeVRX
Copy link

SlimeVRX commented Aug 1, 2023

openexr==1.3.8 work with Google Colab

@Steinthor
Copy link

I'm trying to see if I can use the latest openexr in Blender's python. I'm using docker images as test environments.

If I try to install with pip:
pip install OpenEXR
where it says
Downloading OpenEXR-1.3.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
I get this exact error covered in this issue.

To try to circumvent this I have tried using a docker image to run:
openexr_git_path="https://github.com/AcademySoftwareFoundation/openexr.git"
git clone ${openexr_git_path} --branch v3.2.0-rc --single-branch --depth 1
cd openexr
mkdir build
cd build
cmake -GNinja ..
ninja -j 6
ninja install
to install OpenEXR, then I try to install python wheel:
cd ../src/wrappers/python
pip install .

But I get an error:
File "/openexr/src/wrappers/python/setup.py", line 20, in <module> with open('src/lib/OpenEXRCore/openexr_version.h', 'r') as f: FileNotFoundError: [Errno 2] No such file or directory: 'src/lib/OpenEXRCore/openexr_version.h'
If I fix the error by adding:
script_path = os.path.dirname(os.path.realpath(__file__))
and changing:
open('src/lib/OpenEXRCore/openexr_version.h', 'r')
to:
open(script_path + '/../../lib/OpenEXRCore/openexr_version.h', 'r')
I get error:
OpenEXR.cpp:42:10: fatal error: ImfIO.h: No such file or directory 42 | #include <ImfIO.h>

Ultimately I'm trying to install this for Blender which has its own python executable and environment in a subfolder, plus it has its own c++ openEXR, but I don't specifically know how I could bind to those via python.

@yellowtailfan
Copy link

@Steinthor Unfortunately I think the PyPI binary packages for 1.3.9 are broken. I recommend trying the work around in #24 (comment):

$ pip3 install OpenEXR==1.3.8

@sanguinariojoe
Copy link
Owner

sanguinariojoe commented Aug 19, 2023 via email

@Steinthor
Copy link

@yellowtailfan Thanks for the suggestion, but I just got more errors:

/usr/bin/ld: cannot find -lHalf

/usr/bin/ld: cannot find -lIlmImf

@yellowtailfan
Copy link

@sanguinariojoe That's great news!

@Steinthor Sorry that didn't work, I'm not sure what else to suggest.

@mentics
Copy link

mentics commented Aug 23, 2023

I was about to file a new issue, but I see this one went through the same process I have been going through.

@Steinthor:
For the cannot find -lHalf and -lIlmImf, that is because OpenEXR used to use those libraries, but they have changed according to this comment on the openexr project about that same error.

One way to resolve it: clone this repo, edit setup.py, and remove those two libs from the line:

libraries = ["Iex", "Half", "Imath", "IlmImf", "z"]
# change the above line to:
libraries = ["Iex", "Imath", "z"]

Then run python setup.py bdist_wheel and it will build a wheel file in the dist directory. Then you can run pip install {path to wheel file} where you need it. You probably need the header files for OpenEXR at least and maybe some other dependencies, but I'm not sure. When I got to this point, it just worked for me.

@sanguinariojoe
Copy link
Owner

sanguinariojoe commented Aug 23, 2023 via email

@mentics
Copy link

mentics commented Aug 23, 2023

Thanks! I see it here in the openexr repository.

It's not in a release yet, but it appears it will be in 3.2.

For anyone else finding this in the next short time before it is formally included (openexr website still says it doesn't have python bindings and links to the other python bindings repo from many years ago), you can get it by:

If you clone the main branch of the openexr repo and build that, you'll need to add a switch during cmake config to build the python wrapper:
cmake -DOPENEXR_BUILD_PYTHON=ON ../openexr/
cmake --build .
then there will be lib file in src/wrappers/python/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants