3

I have been trying to include Python.h in c++ file.

#include "Python.h"

int main() {
    return 0;
}

This gives

fatal error: Python.h: No such file or directory

compilation terminated.

upon compilation.

I have correctly installed and added the directory to the PATH

echo $PATH
/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/include:/usr/local/lib:/usr/include/python2.7

What could be the problem?

Doug T.
  • 64,223
  • 27
  • 138
  • 202
foothill
  • 483
  • 3
  • 8
  • 18
  • 2
    Compilers don't use the PATH they use the INCLUDE PATH to find include files. If you tell us what operating system and compiler you are using, we could tell you more. – GreenAsJade Feb 09 '14 at 04:59
  • I'm using ubuntu 12.04 and I got the compiler by sudo apt-get install g++ – foothill Feb 09 '14 at 05:17
  • So i have bunch of files in Python2.7 folder should I move those .h files to the /usr/include directory? – foothill Feb 09 '14 at 05:20
  • I just solved the problem by putting all .h files to the /usr/include directoy and compile with the flag -lpython2.7. How can I make this question as solved? – foothill Feb 09 '14 at 05:25
  • Post the answer as an answer and accept it :) – GreenAsJade Feb 09 '14 at 05:32
  • As @GreenAsJade said, but note that there are waiting periods for answering you own question and marking it as accepted: http://stackoverflow.com/help/self-answer – Adi Inbar Feb 09 '14 at 06:59

0 Answers0