2

i wanted to run Python-Scripts with C++.

At my book, there is following:

#include <Python.h>
... at main function some calls

But at compiling the Compiler can't find the Python header file.

How can i fix this?

4
  • depends on the platform you are using. On linux, you'll need to install the python-devel package (how you do that also depends on the specific distro). Commented Mar 2, 2014 at 19:44
  • On a Debian-based distribution, the package would actually be called python-dev. Commented Mar 2, 2014 at 20:10
  • i have linux mint, how should it called there? Commented Mar 2, 2014 at 20:11
  • Don't work yet, can't find the header...I donwloaded the python-dev..but can't find header-file... Commented Mar 2, 2014 at 20:42

1 Answer 1

2

On Linux Mint sudo apt-get install python-dev should do the job. This will get and install the python development files.

This should put the include files at /usr/include/python2.7/ so you need to add -l /usr/include/python2.7/ to your compiler flags.

`

Sign up to request clarification or add additional context in comments.

4 Comments

I installed this, but at compiling: martin@ThinkPad ~/Schreibtisch $ g++ pytest.cpp -o pytest pytest.cpp:1:20: fatal error: Python.h: Datei oder Verzeichnis nicht gefunden #include <Python.h> ^ compilation terminated.
Don't work yet, can't find the header...I donwloaded the python-dev..but can't find header-file...
See above about the path.
Don't work...I add the Path-Linker, but still same error, but at this folder the Python.h file is in...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.