jamesbowman/openexrpython

pip install error: Cannot open include file: 'ImathBox.h'

jamietelford opened this issue · 14 comments

Hi James,

I have built OpenEXR etc using the script provided at https://github.com/vfxpro99/usd-build-club

However I can't link the ImathBox.h which has been built to C:\EXR\OPENEXR

any tips would be awesome..

thanks bro!

oh.. I did not know about the prebuilt binaries.. thx!

I did manage to include ImathBox.h but got another error

OpenEXR.cpp(1233): error C2059: syntax error: 'constant' error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2

anyway.. I'll have a go with the prebuilt binaries..

tuket commented

I had the same problem installing from pip. I will try those prebuilt binaries.

This issue exists on macOS High Sierra, but I solved it with the following (requires homebrew):

  • brew install openexr
  • sudo pip install openexr

@nedwilson it works. openexr installed successfully. But when I tried to import openexr, a new error occured:

ImportError: dlopen(/anaconda/envs/tf1/lib/python2.7/site-packages/OpenEXR.so, 2): Symbol not found: __ZN7Imf_2_214TypedAttributeISsE13readValueFromERNS_7IStreamEii
Referenced from: /anaconda/envs/tf1/lib/python2.7/site-packages/OpenEXR.so
Expected in: flat namespace
in /anaconda/envs/tf1/lib/python2.7/site-packages/OpenEXR.so

@uathena1991 Using other python version(3.5 or 2)will be be fine.

@nedwilson it works. openexr installed successfully. But when I tried to import openexr, a new error occured:

ImportError: dlopen(/anaconda/envs/tf1/lib/python2.7/site-packages/OpenEXR.so, 2): Symbol not found: __ZN7Imf_2_214TypedAttributeISsE13readValueFromERNS_7IStreamEii
Referenced from: /anaconda/envs/tf1/lib/python2.7/site-packages/OpenEXR.so
Expected in: flat namespace
in /anaconda/envs/tf1/lib/python2.7/site-packages/OpenEXR.so

I am having the same issue trying to install on OSX 10.13.6
I have tried building openexr from source and building these bindings from source.

Please look at
https://github.com/openexr/openexr/issues/207#issuecomment-459156456

I'm not sure why this is happening and it's now prevented me from doing a good amount of work.
any ideas @jamesbowman? any insights would be greatly appreciated

Here's an example of how I've modified the setup.py to account for my miniconda installation.
setup.txt

The build is successful and when i run
otool -L build/lib.macosx-10.6-x86_64-2.7/OpenEXR.so
I get
@rpath/libIex-2_3.24.dylib (compatibility version 24.0.0, current version 2.3.0)
@rpath/libHalf-2_3.24.dylib (compatibility version 24.0.0, current version 2.3.0)
@rpath/libImath-2_3.24.dylib (compatibility version 24.0.0, current version 2.3.0)
@rpath/libIlmImf-2_3.24.dylib (compatibility version 24.0.0, current version 2.3.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)

but still python -c "import OpenEXR" gives me:
Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: dlopen(/Users/jbartolozzi/miniconda2/lib/python2.7/site-packages/OpenEXR.so, 2): Symbol not found: __ZN7Imf_2_314TypedAttributeISsE13readValueFromERNS_7IStreamEii Referenced from: /Users/jbartolozzi/miniconda2/lib/python2.7/site-packages/OpenEXR.so Expected in: flat namespace in /Users/jbartolozzi/miniconda2/lib/python2.7/site-packages/OpenEXR.so

I have solved the problem above by modifying the setup.py to the following:
setup.txt

Edit Confirming that this works on OSX 10.13.6 with the openexr 2.3.0 libs from
conda install -c conda-forge openexr

@jamietelford
my pc is ubuntu 16 64bit,pip install openexr error, try your method,
conda install -c conda-forge openexr
it is well installed
but when in pythonfile, import OpenEXR,, error log
import OpenEXR
ModuleNotFoundError: No module named 'OpenEXR'

@zkl99999 : Were you able to fix above 'ModuleNotFoundError' ? I ran into the exact same issue after successful installation by 'conda install -c conda-forge openexr'.
[Edit- Ans]: Realized that above method installs c++ based version & doesn't have python binding, and hence cant be imported in python environment.
@jamietelford and @jamesbowman : Q1) Can you elaborate steps to install prebuilt windows library from http://www.lfd.uci.edu/~gohlke/pythonlibs/ ?
[Edit - Ans]: OpenEXR‑1.3.2‑cp37‑cp37m‑win_amd64.whl worked on my system (win8, 64b, python 3.7). Now, 'import OpenEXR' works in python :)!
Thanks all!

For Ubuntu (and Debian?) it can be solved with sudo apt install libopenexr-dev, so that you pull in the header that gcc is complaining about in the pip build.

ckxz commented

Hi @ittim4,
I'm facing the exact same issue you did. Could you please elaborate the steps you followed to insall the prebuilt windows library from http://www.lfd.uci.edu/~gohlke/pythonlibs/?
Thanks!

Edit: Figured it out. To anyone interested, 1. download prebuilt library (e.g. OpenEXR‑1.3.2‑cp37‑cp37m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#openexr), 2. access directory where .whl file has been downloaded from command line, 3. run pip install OpenEXR‑1.3.2‑cp37‑cp37m‑win_amd64.whl. Discussed in detail here.

@zkl99999 : Were you able to fix above 'ModuleNotFoundError' ? I ran into the exact same issue after successful installation by 'conda install -c conda-forge openexr'.
[Edit- Ans]: Realized that above method installs c++ based version & doesn't have python binding, and hence cant be imported in python environment.
@jamietelford and @jamesbowman : Q1) Can you elaborate steps to install prebuilt windows library from http://www.lfd.uci.edu/~gohlke/pythonlibs/ ?
[Edit - Ans]: OpenEXR‑1.3.2‑cp37‑cp37m‑win_amd64.whl worked on my system (win8, 64b, python 3.7). Now, 'import OpenEXR' works in python :)!
Thanks all!

i used the method by @ckxz mention above and it worked great - Thanks!!

Edit: Figured it out. To anyone interested, 1. download prebuilt library (e.g. OpenEXR‑1.3.2‑cp37‑cp37m‑win_amd64.whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#openexr), 2. access directory where .whl file has been downloaded from command line, 3. run pip install OpenEXR‑1.3.2‑cp37‑cp37m‑win_amd64.whl. Discussed in detail here.