Yelp / MOE

A global, black box optimization engine for real world metric optimization.
Other
1.3k stars 139 forks source link

Build error: Could NOT find PythonLibs (missing: PYTHON_INCLUDE_DIRS) #465

Closed gokceneraslan closed 8 years ago

gokceneraslan commented 8 years ago

When I try to compile MOE with python from miniconda2, I get this error:

running install_scripts
Could not find env var MOE_CMAKE_PATH for cmake, using /usr/bin/cmake from $PATH
Passing '-D MOE_PYTHON_INCLUDE_DIR=/usr/include/python2.7/ -D MOE_PYTHON_LIBRARY=/usr/lib//x86_64-linux-gnu/libpython2.7.so' args from MOE_CMAKE_OPTS to cmake.
PYTHON_INCLUDE_DIR (Expected full path to where Python.h is found): /home/g/miniconda2/include/python2.7
PYTHON_LIBRARY (Expected path to Python shared object; e.g., libpython2.7.so or .dylib): /home/g/miniconda2/lib/libpython2.7.so.1.0
-- The C compiler identification is GNU 4.8.4
-- The CXX compiler identification is GNU 4.8.4
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
  Could NOT find PythonLibs (missing: PYTHON_INCLUDE_DIRS) (found version
  "2.7.6")
Call Stack (most recent call first):
  /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-2.8/Modules/FindPythonLibs.cmake:208 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:75 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/g/Code/MOE/moe/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.
error: [Errno 2] No such file or directory: '/home/g/Code/MOE/moe/build/GPP.so'

I can compile it only if I apply the following patch:

diff --git a/moe/optimal_learning/cpp/CMakeLists.txt b/moe/optimal_learning/cpp/CMakeLists.txt
index 2ea50e8..0bc6ee5 100644
--- a/moe/optimal_learning/cpp/CMakeLists.txt
+++ b/moe/optimal_learning/cpp/CMakeLists.txt
@@ -42,7 +42,7 @@ endif()
 # User specifies what directory to look for Python headers in
 if (DEFINED MOE_PYTHON_INCLUDE_DIR)
   if (IS_DIRECTORY ${MOE_PYTHON_INCLUDE_DIR})
-    set(PYTHON_INCLUDE_DIR
+    set(PYTHON_INCLUDE_DIRS
       ${MOE_PYTHON_INCLUDE_DIR}
       CACHE PATH "*Full* path to where Python.h is found."
       )

Is it correct to set PYTHON_INCLUDE_DIR variable in CMakeLists.txt or should it be PYTHON_INCLUDE_DIRS?

gokceneraslan commented 8 years ago

OK, this seems to be a bug in /usr/share/cmake-2.8/Modules/FindPythonLibs.cmake file in Ubuntu 14.04.4, not related to MOE at all. Following patch fixed the problem, I'm closing the bug:

diff --git a/FindPythonLibs.cmake b/FindPythonLibs.cmake
index 1cf6bde..61c83d2 100644
--- a/FindPythonLibs.cmake
+++ b/FindPythonLibs.cmake
@@ -190,7 +190,7 @@ mark_as_advanced(
 # cache entries because they are meant to specify the location of a single
 # library. We now set the variables listed by the documentation for this
 # module.
-set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}" "${PYTHON_INCLUDE_DIR2}")
+set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
 set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")

 # These variables have been historically named in this module different from