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.
So far I've,
- installed Python 3.5.1,
- included this path:
...\Python\Python35-32\include
, which let me include thePython.h
library, - added this path:
...\Python\Python35-32\libs
to access the lib files, andpython35.lib
as dependency inLinker\Input
setting of MSVS15, - then there an error occurred, demanding
python35_d.lib
, so I compiled Python's source inDebug
mode & copied that file to that...\libs
folder and it solved the problem.
This all happened when I was trying to run this only-
Py_Initialize();
PyRun_SimpleString("print (\"Hello World!\\n\")");
Py_Finalize();
Now I'm trying to run a Python function from a .py
file. I'm trying to run this from the Python tutorials but I'm getting this error -
While debugging, I have found that when this macro gets called: Py_DECREF()
, this error occurs.
Do I only need to copy python35_d.dll
from PCBuild\win32
to C:\Windows\[System|System32|SysWOW64]\
to solve the problem as I don't know if it'll have any side-effects?
Although the file is already present in ...\Python\Python35-32\DLLs\
.
Is there a proper setup to be done before running Python in C/C++ using MSVS, like this for Unix-like systems? (I mean by adding other dependencies or folders to the settings)
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.
Can somebody guide/enlighten me for something I may be missing because I'm continuously getting errors here & there, please?
Thanks.