python3 and macOS

Hi all,

If turn on VTK_WRAP_PYTHON on a recent version of macOS with Xcode installed, it finds:

 Python3_EXECUTABLE              */Applications/                                     

 Python3_INCLUDE_DIR             */Applications/                                 

 Python3_LIBRARY                 */Applications/                            

But then running tests fail with:

Library not loaded: @rpath/Python3.framework/Versions/3.8/Python3
Referenced from: /Users/builder/external/VTK-test/bin/vtkpython
Reason: tried: '/Users/builder/external/VTK-test/lib/Python3.framework/Versions/3.8/Python3' (no such file), '/Applications/' (no such file), '/Users/builder/external/VTK-test/lib/Python3.framework/Versions/3.8/Python3' (no such file), '/Applications/' (no such file), '/Library/Frameworks/Python3.framework/Versions/3.8/Python3' (no such file), '/System/Library/Frameworks/Python3.framework/Versions/3.8/Python3' (no such file)

I suppose I can fix this by installing my own python, but… perhaps there is something that should be fixed here?


So the above path exists in the SDK, but it doesn’t exist on the system itself? Or does it not exist in the SDK, either?

This is the “terrible rpath” issue on macOS. The library says “you need to use rpath to use me” (with the @rpath/ library id), but nothing says what path to actually add. Here, you’ll need to do it manually. See how CI does it.

I have discussed it in the CMake Discourse before (and maybe even an issue), but libraries will need an IMPORTED_RPATH property to be set so that CMake can know to add the right -Wl,-rpath, flags to the linker.

OK, that worked. Many more tests passing today. But there are still some “not run” tests saying that numpy is required:

I guess maybe the Xcode python3 doesn’t include that? I guess just installing python3 is preferable then on macOS…?

No, Xcode’s Python is (AFAIK), just the stdlib. You can make a virtualenv with the Xcode Python just fine (it’s what CI does).

So I’ve installed python from then run python3 -m pip install numpy to get numpy. Many tests fail though:


Traceback (most recent call last):
  File "/Users/builder/external/VTK/IO/Geometry/Testing/Python/", line 2, in <module>
    import vtk
ModuleNotFoundError: No module named 'vtk'

Anyone know why this might be? (I know next to nothing about how python works…)


My guess is that you installed Python 3.10, which breaks the testing due to this issue.

Bingo David! I guess I’ll downgrade to 3.9…

The downgrade to python 3.9 worked on Rogue20, so I’ve done it for all my other bots. Should be greener tomorrow.

Thanks for maintaining those bots. The CI bots don’t always catch everything.