title: Error: 'python35_d.dll is missing' while running C++ code with Python in MS Visual Studio 2015
body: <p>I am trying to embed Python in my C++ code to use WordNet through nltk. I am new to Python and I am using MS Visual Studio 2015 to do the same but I'm facing problems to use Python on MSVS 15.</p>
  
  <p>So far I've,</p>
  
  <ul>
  <li>installed Python 3.5.1,</li>
  <li>included this path: <code>...\Python\Python35-32\include</code>, which let me include the <code>Python.h</code> library,</li>
  <li>added this path: <code>...\Python\Python35-32\libs</code> to access the lib files, and <code>python35.lib</code> as dependency in <code>Linker\Input</code> setting of MSVS15,</li>
  <li>then there an error occurred, demanding <code>python35_d.lib</code>, so I compiled Python's source in <code>Debug</code> mode &amp; copied that file to that <code>...\libs</code> folder and it solved the problem.</li>
  </ul>
  
  <p>This all happened when I was trying to run this only-</p>
  
  <pre><code>Py_Initialize();
  PyRun_SimpleString("print (\"Hello World!\\n\")");
  Py_Finalize();
  </code></pre>
  
  <p>Now I'm trying to run a Python function from a <code>.py</code> file. I'm trying to run <a href="https://docs.python.org/3.5/extending/embedding.html#pure-embedding" rel="nofollow noreferrer">this</a> from the <a href="https://docs.python.org/3.5/extending/index.html" rel="nofollow noreferrer">Python tutorials</a> but I'm getting this error - </p>
  
  <p><a href="https://i.stack.imgur.com/MLcYh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MLcYh.jpg" alt="enter image description here"></a></p>
  
  <p>While debugging, I have found that when this macro gets called: <code>Py_DECREF()</code>, this error occurs.</p>
  
  <p>Do I only need to copy <code>python35_d.dll</code> from <code>PCBuild\win32</code> to <code>C:\Windows\[System|System32|SysWOW64]\</code> to solve the problem as I don't know if it'll have any side-effects?</p>
  
  <p>Although the file is already present in <code>...\Python\Python35-32\DLLs\</code>.</p>
  
  <p>Is there a proper setup to be done before running Python in C/C++ using MSVS, like <a href="https://docs.python.org/3.5/extending/embedding.html#compiling-and-linking-under-unix-like-systems" rel="nofollow noreferrer">this</a> for Unix-like systems? (I mean by adding other dependencies or folders to the settings)</p>
  
  <p>I've been reading Python documentation continuously and even other stackoverflow questions but I'm still struggling a lot (I don't know why) even to do simple things.</p>
  
  <p>Can somebody guide/enlighten me for something I may be missing because I'm continuously getting errors here &amp; there, please?</p>
  
  <p>Thanks.</p>