title: Could NOT find PythonLibs, anaconda3
body: <p>ORIGINAL POST:</p>
  
  <p>I am trying to compile a simple 'hello world' to call from python (anaconda3), complied using CMake.</p>
  
  <p>I get:</p>
  
  <pre><code>Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
  </code></pre>
  
  <p>hello.cpp:</p>
  
  <pre><code>#include &lt;boost/python.hpp&gt;
  #include &lt;string&gt;
  
  std::string greet(std::string name){
      return std::string("Hello, ") + name;
  }
  
  BOOST_PYTHON_MODULE(hello){
      using namespace boost::python;
      def("greet", greet, "Prepends a greeting to the passed name");
  }
  </code></pre>
  
  <p>CMakeLists.txt:</p>
  
  <pre><code>cmake_minimum_required(VERSION 3.0)
  find_package(PythonLibs 3 REQUIRED)
  
  set(BOOST_PYTHONLIB python-py36)
  find_package(Boost COMPONENTS ${BOOST_PYTHONLIB})
  
  python_add_module(hello hello.cpp)
  target_include_directories(hello PUBLIC ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
  target_link_libraries(hello ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
  </code></pre>
  
  <p>Crucally, I'm trying to use anaconda3, so based on some other posts I've added the following arguments for when CMake is called:</p>
  
  <pre><code>-DPYTHON_LIBRARY=/Users/chris/anaconda3/lib
  -DPYTHON_INCLUDE_DIR=/Users/chris/anaconda3/include
  </code></pre>
  
  <p>But I get the same error with or without these arguments. I'm still relatively new to this, so apologies if this is something trivial.</p>
  
  <p>I'm running Mojave 10.14.6, and I'm doing this through CLion.</p>
  
  <p>UPDATE:</p>
  
  <p>As suggested in <a href="https://stackoverflow.com/questions/42445169/pythonlibs3-cmake-and-macos">this</a>post, editing the package finds to </p>
  
  <pre><code>FIND_PACKAGE(PythonInterp 3)
  FIND_PACKAGE(PythonLibs 3)
  </code></pre>
  
  <p>Seems to help - it finds PythonLibs but not the correct one.</p>
  
  <pre><code>Could NOT find PythonLibs: Found unsuitable version "2.7.10", but required is at least "3" (found /usr/lib/libpython2.7.dylib)
  </code></pre>
  
  <p>I am aware that I can (in principle) do:</p>
  
  <pre><code>set(PYTHON_LIBRARIES /Users/chris/anaconda3/lib/libpython3.6m.dylib)
  </code></pre>
  
  <p>As discussed in the comments, which does find the correct library, but as discussed in the above post, later gives me the error <code>Unknown CMake command "PYTHON_ADD_MODULE".</code></p>
  
  <p>According to that post, the "reason for this appears to be because this function is provided by FindPythonLibs.cmake which is loaded in by find_package(Pythonlibs) and therefore, if this is not used to located PythonLibs, this function cannot be called".</p>
  
  <p>So, it seems that the path to <code>/Users/chris/anaconda3/lib/libpython3.6m.dylib</code> needs to be somehow added to FindPackage()s search. Anyone know how to do this?</p>