title: Embedding pybind11 with virtual environment
body: <p>I'm trying to embed python using pybind11 into my C++ application. Using the following CMake property, I managed to compile against a virtual environment of my project.</p>
  
  <pre><code>-DPYTHON_EXECUTABLE:FILEPATH=C:/Python/Envs/myproject/Scripts/python.exe
  </code></pre>
  
  <p>When I run the application I get an error (below) without a specific error. However I assume it fails to load the module numpy which I'm loading.</p>
  
  <blockquote>
    <p>abort() has been called</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;pybind11/embed.h&gt;
  
  namespace py = pybind11;
  
  int main() {
      py::scoped_interpreter guard{};
      auto sys = py::module::import("sys");
      py::print("Hello, World from Python!");
      py::print(sys.attr("executable"));
      py::print(sys.attr("version"));
      // works until here
  
      auto np = py::module::import("numpy");
      py::print(np.attr("version"));
  
      return EXIT_SUCCESS;
  }
  </code></pre>
  
  <p>If I only import the sys module (which is in the standard library) the application works fine. This is the output of the application until the crash:</p>
  
  <pre><code>Hello, World from Python!
  C:\Develop\sandbox\python_binding\cmake-build-debug\bin\python_binding.exe
  3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
  </code></pre>
  
  <p>I've added the following directories to my PATH.</p>
  
  <blockquote>
    <p>PATH=C:\Python\Envs\project\Scripts;C:\Python\Envs\project\Lib</p>
  </blockquote>
  
  <p>Do I have to specify the paths to other parts of the python interpreter I'm using or could this be caused by another problem?</p>