A little background: a colleague of mine was trying to install this useful library (to process RAW photo files as Ian Wootten has written about) which doesn’t have a very user-friendly README file on their GitHub repo. He was getting the following error:
Traceback (most recent call last): File "a.py", line 1, in <module> import OpenImageIO as oiio ImportError: No module named OpenImageIO
- In order to fix it, you need to have Homebrew installed. If you already have it installed run
brew updateto make sure you have the latest version.
- If you don’t currently have it, install Python 2.7. You can do so running in your Terminal:
brew install python. That should take care of installing
pipas well (which is the Python package manager, and it is very useful most of the times, though it doesn’t have
- We can then proceed to (finally) do
brew install homebrew/science/openimageio, or the whole
sciencemodule. I did only the first.
- Because Homebrew likely installed the module .so file in a directory that’s not being used by Python, we have to symlink the file to one that Python uses. You can locate the Homebrew file at
- Now, I was wondering where does Python import modules from? Running
python -c 'import sys; print sys.path'would return an array of all paths where it tries to find modules on import. In my case, I just took the last “site-packages” one, which was
/Library/Python/2.7/site-packages– Please note this path might defer with yours.
- Last step, and this is all that matters, is taking the path from #4 and putting it into #5:
ln -s /usr/local/Cellar/openimageio/1.7.7_1/lib/python2.7/python/OpenImageIO.so /Library/Python/2.7/site-packages/OpenImageIO.so
And you should now be good to go, to run any
import OpenImageIO.so as oiio all you want. I hope this article saved you the 2 hours I’ve spent figuring it out.