0

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 the Python.h library,
  • added this path: ...\Python\Python35-32\libs to access the lib files, and python35.lib as dependency in Linker\Input setting of MSVS15,
  • then there an error occurred, demanding python35_d.lib, so I compiled Python's source in Debug 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 -

enter image description here

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.

PalashV
  • 759
  • 3
  • 8
  • 25

1 Answers1

0

copy python35.dll into the folder where .sln file is present

  • Welcome to stackoverflow. Stackoverflow is not a forum, please keep the structure of it. This is more a comment than an answer. When you have enough reputation you can post comment. – Kenzo_Gilead Sep 04 '17 at 10:49
  • 2
    @EliasMP I disagree. He attempted to answer the question it might not be correct. See comment by *David Marquant* on the question. This answer could be considered *LQ* though. – Noel Widmer Sep 04 '17 at 11:13