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

fatal error: 'ImfIO.h' file not found, PyCharm terminal, MacOs : Ventura #28

Open
TUGCE12 opened this issue Jul 27, 2023 · 2 comments
Open

Comments

@TUGCE12
Copy link

TUGCE12 commented Jul 27, 2023

The error I get when I run pip install openexr from PyCharm Terminal on Mac M2, Ventura 13.4.1 Computer.

% pip install openexr                                                                             
  Building wheel for openexr (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      Looking for libOpenEXR...
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.9-universal2-3.9
      copying Imath.py -> build/lib.macosx-10.9-universal2-3.9
      running build_ext
      creating build/temp.macosx-10.9-universal2-3.9
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -Wno-error=unreachable-code -I/usr/include/OpenEXR -I/usr/local/include/OpenEXR -I/opt/local/include/OpenEXR -I/usr/include/Imath -I/usr/local/include/Imath -I/opt/local/include/Imath -I/.../venv/include -I/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.9/include/python3.9 -c OpenEXR.cpp -o build/temp.macosx-10.9-universal2-3.9/OpenEXR.o -g -DVERSION=\"1.3.9\" -std=c++11 -Wc++11-extensions -Wc++11-long-long
      **OpenEXR.cpp:36:10: fatal error: 'ImfIO.h' file not found**
      #include <ImfIO.h>
               ^~~~~~~~~
      1 error generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for openexr
  Running setup.py clean for openexr
Failed to build openexr
ERROR: Could not build wheels for openexr, which is required to install pyproject.toml-based projects


It didn't work either when I ran these commands:

git clone https://github.com/sanguinariojoe/pip-openexr.git
cd pip-openexr
sudo python setup.py install

and I got the same error:

OpenEXR.cpp:36:10: fatal error: 'ImfIO.h' file not found
#include <ImfIO.h>
          ^~~~~~~~~
1 error generated.
@paolovalerdi
Copy link

I had the same error. If anyone faces this issue I was able to solve following these steps:

First install openexr using homebrew
brew install openexr

Then I cloned the repo
git clone [email protected]:sanguinariojoe/pip-openexr.git

After that I edited the setup.py file as per this comment. In my case the version homebrew installed is 3.1.9. So those lines look like this:

setup.py:

include_dirs = [
    "/usr/include/OpenEXR",
    "/usr/local/include/OpenEXR",
    "/opt/local/include/OpenEXR",
    "/usr/include/Imath",
    "/usr/local/include/Imath",
    "/opt/local/include/Imath",
    "/opt/homebrew/opt/openexr/3.1.9/lib",
    "/opt/homebrew/opt/imath//3.1.9/lib",
]

library_dirs = [
    "/usr/lib",
    "/usr/local/lib",
    "/opt/local/lib",
    "/opt/homebrew/opt/openexr/3.1.9/lib",
    "/opt/homebrew/opt/imath//3.1.9/lib",
]

Finally I just ran the setup file using
python setup.py install

Hope this helps anyone facing this issue :)

@JGroxz
Copy link

JGroxz commented Aug 11, 2023

There is an alternative way without editing setup.py (originally found it here):

  1. Install through brew:
    brew install openexr
  2. Define these:
    # These environment variables are required for OpenEXR pip package to compile
    export CFLAGS="-I/opt/homebrew/include/OpenEXR -I/opt/homebrew/include/Imath -std=c++11"
    export LDFLAGS="-L/opt/homebrew/lib"
  3. Install:
    pip install openexr

I hope this helps!

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

3 participants