Error "could not find PythonLibs" when building extension

build

(Csaba Pinter) #1

I’m trying to build SlicerVirtualReality on Windows, but I’m getting this error:

3> CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
3>    Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)

after which I’m getting this error:

4>  CMake Error at C:/d/S4R/VTK/CMake/vtkModuleAPI.cmake:140 (message):
4>    Requested modules not available:
4>
4>      vtkRenderingOpenVR
4>  Call Stack (most recent call first):
4>    C:/d/S4R/VTK-build/VTKConfig.cmake:130 (vtk_module_config)
4>    VirtualReality/MRML/CMakeLists.txt:6 (find_package)

I’m not sure if they are related, but I have the feeling they are, because I can build other extensions like MarkupsToModel or SlicerRT without problems.

The reason this computer is different from my other computers on which SlicerVirtualReality builds fine is that I installed a Python 3.7 on this one. There was nothing in the environment variables related to that other python installation other than a path, but the error didn’t go away after removing that either.

Does anyone has an idea what to try next? Thanks a lot!


(Jean Christophe Fillion Robin) #2

It looks like something is resetting the value of PYTHON_LIBRARY and PYTHON_INCLUDE_DIR CMake cache variable in the extension build tree.

If you add there lines after finding Slicer in KitwareMedical/SlicerVirtualReality/CMakeLists.txt:

message("PYTHON_LIBRARY :${PYTHON_LIBRARY}")
message("PYTHON_INCLUDE_DIR :${PYTHON_INCLUDE_DIR}")

is there value correct ?

If yes, I suggest you do the same inRendering/OpenVR/CMakeLists.txt

That should allow you to find out what is resetting the variables …


(Csaba Pinter) #3

Thanks for the suggestions, @jcfr!

Yes, the variables have the correct values in both the main SlicerVR CmakeLists.txt, and both in the one where the second error occurs (I put it just before line 6):

3>  PYTHON_LIBRARY :C:/d/S4R/python-install/libs/python27.lib
3>  PYTHON_INCLUDE_DIR :C:/d/S4R/python-install/include

Rendering/OpenVR/CMakeLists.txt does not give me any output, I guess it never gets that far.


(Jean Christophe Fillion Robin) #4

Also what is the full stack, where does the error originate ?


(Csaba Pinter) #5

Here it is:

3>------ Build started: Project: VTKRenderingOpenVR, Configuration: Release x64 ------
...
3>  CMake Error at C:/Program Files/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
3>    Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
3>  Call Stack (most recent call first):
3>    C:/Program Files/CMake/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
3>    C:/d/S4R/VTK/CMake/FindPythonLibs.cmake:213 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
3>    C:/d/S4R/VTK/CMake/vtkWrapPython.cmake:167 (find_package)
3>    C:/d/S4R/VTK/CMake/vtkInitializeWrapPython.cmake:4 (include)
3>    C:/d/S4R/VTK/CMake/vtkExternalModuleMacros.cmake:15 (include)
3>    CMakeLists.txt:8 (include)

(Jean Christophe Fillion Robin) #6

Then, could you check that the variable are set before the call of vtkExternalModuleMacros here


(Csaba Pinter) #7

Good point, sorry!

2>  PYTHON_LIBRARY :PYTHON_LIBRARY-NOTFOUND
2>  PYTHON_INCLUDE_DIR :

So one says not found, the other one is empty.
Not sure why it’s not propagated. Thanks!


(Jean Christophe Fillion Robin) #8

Could you try adding:

-DPYTHON_LIBRARY:FILEPATH=${PYTHON_LIBRARY}
-DPYTHON_INCLUDE_DIR:PATH=${PYTHON_INCLUDE_DIR}

to https://github.com/KitwareMedical/SlicerVirtualReality/blob/master/SuperBuild/External_VTKRenderingOpenVR.cmake#L38


(Csaba Pinter) #9

An update about this:
I removed all python-related environment variables and paths, which didn’t seem to solve the problem. Then I went on vacation for a few weeks, which involved windows update (and thus restart). Now I’m back and rebased SlicerVR on the master, tried to build, and now it worked. So either the env.var. thing or the update/restart, or both solved it. Thanks for the pointers.