Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use Arch Linux. I want to compile a C++ file that includes <Python.h>. But I can't do it.

In Debian based systems this problem is resolved with sudo apt-get install python-dev. How I can install this package with pacman?

* EDIT *

I wan't to compile this file


#include "Python.h"
int main(int argc, char *argv[])
  Py_SetProgramName(argv[0]);  /* optional but recommended */
  PyRun_SimpleString("from time import time,ctime\n"
                     "print 'Today is',ctime(time())\n");
  return 0;

run this command:

g++ C.c

and i have this error:

call_function.c:1:20: fatal error: Python.h: No such file or directory
 #include "Python.h"
compilation terminated.
share|improve this question
Both the python and python2 package in Arch Linux contain a Python.h file, you don't need an extra package. What's the exact error message you're getting and what is your include path? – Wieland Dec 8 '13 at 23:11
I can't compile this #include<Python.h> with gcc – 2 8 Dec 9 '13 at 5:42
@28 just tell us what Wieland asked you to tell. – Risto Salminen Dec 9 '13 at 6:16
I edit this question – 2 8 Dec 9 '13 at 10:14
up vote 6 down vote accepted

You should compile your files with libs and cflags provided by python package:

gcc py.c $(pkg-config --cflags --libs python2) -o py

Besides, it should be #include <Python.h> instead.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.