openexr icon indicating copy to clipboard operation
openexr copied to clipboard

Python binding installation issues on OSX. Symbol not found: __ZTIN13IlmThread_2_04TaskE

Open mikeroberts3000 opened this issue 7 years ago • 18 comments

Hello there,

I'm trying to get the OpenEXR Python bindings to work in my Python environment on OSX. So far, I've tried to install OpenEXR using Macports (i.e., sudo port install openexr which installs the C++ headers and libraries), and then use pip to install the Python bindings (i.e., pip install openexr). This installation procedure seems to work. However, when I try to import OpenEXR, I get the following error message:

ImportError: dlopen(/Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/OpenEXR.so, 2): Symbol not found: __ZTIN13IlmThread_2_04TaskE
  Referenced from: /Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/OpenEXR.so
  Expected in: flat namespace
 in /Users/mike/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/OpenEXR.so

Is what I'm doing a supported scenario? What is the recommended way of getting the OpenEXR Python bindings working on OSX?

mikeroberts3000 avatar Oct 01 '16 19:10 mikeroberts3000

Update: I get similar errors (i.e., "symbol not found; expected in flat namespace"), regardless of whether or not I use sudo port install openexr to install the OpenEXR C++ libraries, or if I build the C++ libraries myself. I've tried to build the C++ libraries with clang and gcc. I've also tried to build and install the Python bindings myself, by running setup.py build, and making sure to specify the CC and CXX environment variables to match the compiler used to build the C++ libraries.

In case anyone is reading this and running into similar issues, I can confirm that based on my experiments, it seems as though these Python bindings don't work on OSX. Or at the very least, it is not clear to me how to get them working.

mikeroberts3000 avatar Oct 02 '16 16:10 mikeroberts3000

Same trouble here, tried multiple ways of getting them to work..

thyselius avatar Oct 31 '17 23:10 thyselius

I also have similar problems with macOS(10.10.5) I think that this problem did not occur with openexr 1.7.0. I'm trying backdating but I am in conflict with ImageMagick. I can not change the environment for a while, but I will report it when I have made any progress. People with similar problems may try backdating.

Old OpenEXR source is here. http://www.openexr.com/downloads.html

KengoSawa2 avatar Nov 11 '17 10:11 KengoSawa2

I have the exact same problem.. Is there still no fix for this? I also tried openexr 1.2.0 but this does not build under python 3. The version from pip install is 1.3.0.

hasan9090 avatar Jan 09 '18 15:01 hasan9090

I think that the cause is Mr jamesbowman(pip openexr author) doesn't fix to python 3. (OpenEXR master library isn't reason) According to some error messages,It seems that c ++ bridge correspondence to python 3 is not done.

Therefore, you may use choice(s)

  1. PyEXR(very simple,easy to use. But I don't use) https://github.com/tvogels/pyexr

  2. openimageio python binding (very complex and difficult to build and install,But full function and support multiple format) https://sites.google.com/site/openimageio/home

I use openimageio with python bindings.

KengoSawa2 avatar Jan 10 '18 07:01 KengoSawa2

Thanks for the info. I will check these out. One question still though, does the problem seem to be connected only with Python environment on Mac OS or purely with Python 3 no matter on which machine it is setup? Can you please give some more info about the two alternatives you mentioned? I am a beginner in this department.. Are these alternatives which nevertheless use the original openEXR c++ library so that code that uses the original openexr functions will work flawlessly or do I have to rewrite functions for this?

hasan9090 avatar Jan 10 '18 09:01 hasan9090

Sorry, I didn't use original c++ openexr library header and function. I Can't answer your question.

If you want to use original OpenEXR function. you had better contact to Mr jamesbowman, or get (Py)OpenEXR source and patch yourself.

cheers!

KengoSawa2 avatar Jan 11 '18 03:01 KengoSawa2

I have the same problem with Python 2.7 on OSX 10.13.4.... I used brew install openexr and pip install openexr...Let me know if you find any solutions.

uathena1991 avatar Jun 06 '18 01:06 uathena1991

I have the same problem with Python 2.7 on OSX 10.13.4.... I used brew install openexr and pip install openexr...Let me know if you find any solutions.

I am also having this problem with Python 2.7 on OSX 10.13.6 with brew + pip

jbartolozzi avatar Jan 30 '19 21:01 jbartolozzi

If I'm not mistaken, the version of openexr in pip is 1.3.2. (https://pypi.org/project/OpenEXR/#history) OpenEXR 1.3.2 is from 2006. I would recommend avoiding using pip to install openexr, as that version has not been supported for many years. There have been dozens and dozens of issues resolved since then.

Brew has OpenEXR 2.2 (https://formulae.brew.sh/formula/). So the OpenEXR in pip and brew are completely incompatible and will have symbol conflicts. 2.2 is from 2014, and also is not the supported version.

One solution is to build OpenEXR yourself. If you follow the "building with cmake" directions at https://github.com/openexr/openexr you should be able to get going with the latest known good code. If you do this you will probably want to brew uninstall openexr first, so you don't get conflicting copies of openexr in your path.

meshula avatar Jan 30 '19 22:01 meshula

@meshula are you recommending using these built dylibs to then build https://github.com/jamesbowman/openexrpython ? Is there a way to build a python module using cmake? Sorry i'm a noob.

Right now I've set up an environment using miniconda. And install openexr with the following: conda install -c conda-forge openexr pip install pyexr

if I use otool -L to look at OpenEXR.so that pyexr installs i get @rpath/libIex-2_3.24.dylib (compatibility version 25.0.0, current version 25.0.0) @rpath/libHalf.24.dylib (compatibility version 25.0.0, current version 25.0.0) @rpath/libImath-2_3.24.dylib (compatibility version 25.0.0, current version 25.0.0) @rpath/libIlmImf-2_3.24.dylib (compatibility version 25.0.0, current version 25.0.0) @rpath/libz.1.dylib (compatibility version 1.0.0, current version 1.2.11) /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)

if i look in the miniconda/lib directory i see: libcrypto.dylib -> libcrypto.1.0.0.dylib libssl.dylib -> libssl.1.0.0.dylib libHalf.dylib -> libHalf.24.dylib libIex.dylib -> libIex-2_3.24.dylib libIexMath.dylib -> libIexMath-2_3.24.dylib libIlmThread.dylib -> libIlmThread-2_3.24.dylib libImath.dylib -> libImath-2_3.24.dylib libIlmImf.dylib -> libIlmImf-2_3.24.dylib libIlmImfUtil.dylib -> libIlmImfUtil-2_3.24.dylib

However running miniconda2/bin/python -c "import OpenEXR" yields: miniconda2/lib/python2.7/site-packages/OpenEXR.so, 2): Symbol not found: __ZN7Imf_2_214TypedAttributeIN9Imath_2_23BoxINS1_4Vec2IfEEEEE13readValueFromERNS_7IStreamEii

Am I missing something here? It looks like the so has the correct dependencies.

jbartolozzi avatar Jan 30 '19 23:01 jbartolozzi

Actually I misunderstood completely. I thought that the openexr python package in pip would be the python bindings that are a distribution of the python bindings for IlmBase which are part of this repo. I understand now that the openexr in pip is an independent project. I will have to re-examine the issue to understand what's going on! Also, it would make a lot of sense to open an issue, cc'ing this one, at the https://github.com/jamesbowman/openexrpython site, since he'll be best equipped to help diagnose what's going on.

meshula avatar Jan 31 '19 20:01 meshula

It‘s really a question, I try many meas to address this undefined symbol issue, but it does't work. Is there anyone found any solutions. Thanks

zkk0911 avatar Apr 01 '19 02:04 zkk0911

On Ubuntu 16.04 with miniconda I was able to do the following: conda install -c conda-forge openexr which installs openexr 2.3.0 I cloned https://github.com/jamesbowman/openexrpython I then manually modified the following lines of https://github.com/jamesbowman/openexrpython/blob/master/setup.py include_dirs=['/path/to/miniconda/include/OpenEXR'], library_dirs=['/path/to/miniconda/lib'], and ran python setup.py install

jbartolozzi avatar Apr 01 '19 03:04 jbartolozzi

HI @jbartolozzi,thanks for your reply. it sounds good solutions. I followed your step, and it still does't work. Steps are as follows. It indeed installed with miniconda inside openexr 2.3.0 since I found the error are different. I wonder if there are any other mistakes. Thanks

1、modify the set.py manually include_dirs=['/raid/home/wangjian/miniconda2/include/OpenEXR'], library_dirs=['/raid/home/wangjian/miniconda2/lib'],

2、python setup.py install

running install running build running build_py running build_ext building 'OpenEXR' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/raid/home/wangjian/miniconda2/include/OpenEXR -I/usr/include/python3.5m -I/raid/home/wangjian/tools/venv/include/python3.5m -c OpenEXR.cpp -o build/temp.linux-x86_64-3.5/OpenEXR.o -g -DVERSION="1.3.2" cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ x86_64-linux-gnu-g++ -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-3.5/OpenEXR.o -L/raid/home/wangjian/miniconda2/lib -lIex -lHalf -lImath -lIlmImf -lz -o build/lib.linux-x86_64-3.5/OpenEXR.cpython-35m-x86_64-linux-gnu.so running install_lib copying build/lib.linux-x86_64-3.5/OpenEXR.cpython-35m-x86_64-linux-gnu.so -> /raid/home/wangjian/tools/venv/lib/python3.5/site-packages byte-compiling /raid/home/wangjian/tools/venv/lib/python3.5/site-packages/Imath.py to Imath.cpython-35.pyc running install_egg_info Removing /raid/home/wangjian/tools/venv/lib/python3.5/site-packages/OpenEXR-1.3.2.egg-info Writing /raid/home/wangjian/tools/venv/lib/python3.5/site-packages/OpenEXR-1.3.2.egg-info

3、check the installation (venv) wangjian@dgx-1:~/miniconda2/lib$ pip list | grep OpenEXR OpenEXR 1.3.2

4、 check the final result, there is still the undefined symbol problem. But I notice that the printing information is different with the installation from pip directly

import OpenEXR Traceback (most recent call last): File "", line 1, in ImportError: python3.5/site-packages/OpenEXR.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZNK7Imf_2_314TypedAttributeISsE12writeValueToERNS_7OStreamEi

if if use the command 'pip install OpenEXR;, the error info is: ImportError: python3.5/site-packages/OpenEXR.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZNK7Imf_2_214TypedAttributeISsE12writeValueToERNS_7OStreamEi

zkk0911 avatar Apr 01 '19 09:04 zkk0911

FWIW, using the gcc demangler, we can find out that the missing symbol in question is:

Imf_2_3::TypedAttribute<std::string>::writeValueTo(Imf_2_3::OStream&, int) const

meshula avatar Apr 01 '19 17:04 meshula

Running into some similar issue today.

Package IlmBase was not found in the pkg-config search path.
Perhaps you should add the directory containing `IlmBase.pc'
to the PKG_CONFIG_PATH environment variable
Package 'IlmBase', required by 'OpenEXR', not found
gyp: Call to 'PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.14:/Users/rchen/.gvm/pkgsets/go1.16.3/global/overlay/lib/pkgconfig:/Users/rchen/.gvm/pkgsets/go1.16/global/overlay/lib/pkgconfig::/usr/local/lib/pkgconfig:/usr/lib/pkgconfig" pkg-config --cflags-only-I vips-cpp vips glib-2.0 | sed s\/-I//g' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/rchen/mup/build-meetup/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/Users/rchen/.nvm/versions/node/v14.16.0/bin/node" "/Users/rchen/mup/build-meetup/node_modules/.bin/node-gyp" "rebuild"
gyp ERR! cwd /Users/rchen/mup/build-meetup/node_modules/sharp

chenrui333 avatar Apr 19 '21 17:04 chenrui333

@chenrui333 The homebrew org is here - https://github.com/Homebrew ~ I'm not sure how to report an issue to the homebrew team, but it seems like an issue with their formula for OpenEXR?

meshula avatar Apr 19 '21 18:04 meshula