Hirshik ram
Hirshik ram

Reputation: 1

How to use python.h

I have included Python.h in my program,when i compile the program it shows multiple errors telling "Unable to open few libraries " error message is as follows

Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 7: Unable to open include file 'patchlevel.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 8: Unable to open include file 'pyconfig.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 9: Unable to open include file 'pymacconfig.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 50: Unable to open include file 'pyport.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 52: Unable to open include file 'pyatomic.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 63: Unable to open include file 'pymath.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 64: Unable to open include file 'pytime.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 65: Unable to open include file 'pymem.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 67: Unable to open include file 'object.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 68: Unable to open include file 'objimpl.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 69: Unable to open include file 'typeslots.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 71: Unable to open include file 'pydebug.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 73: Unable to open include file 'bytearrayobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 74: Unable to open include file 'bytesobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 75: Unable to open include file 'unicodeobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 76: Unable to open include file 'longobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 77: Unable to open include file 'longintrepr.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 78: Unable to open include file 'boolobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 79: Unable to open include file 'floatobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 80: Unable to open include file 'complexobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 81: Unable to open include file 'rangeobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 82: Unable to open include file 'memoryobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 83: Unable to open include file 'tupleobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 84: Unable to open include file 'listobject.h'
Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 85: Unable to open include file 'dictobject.h'
Error E2228 C:\Borland\bcc55\INCLUDE\Python.h 85: Too many error or warning messages
*** 26 errors in Compile ***

and I did not include any of the above mentioned missing libraries in my program

#include<stdio.h>
#include<Python.h>
int main()
{
     Py_SetProgramName(argv[0]);  
     Py_Initialize();
     PyRun_SimpleString("print("hello")");
     Py_Finalize();
     return 0;
}

Upvotes: 0

Views: 1389

Answers (2)

Twonky
Twonky

Reputation: 806

The error message

Error E2209 C:\Borland\bcc55\INCLUDE\Python.h 7: Unable to open include file 'patchlevel.h'

indicates that the error (unable to open file) was introduced by the file python.h in line 7. You might not have included all those header files, but your python.h might.

However,

  1. try to find out where those files are stored on your computer. Then
  2. find out how to tell your compilere where to search for additional include files and provide the location you found the files. Without doing so, the compiler just looks at certain pre-configured directories which are, in your case, not sufficient.

Upvotes: 1

Jordan Bri&#232;re
Jordan Bri&#232;re

Reputation: 1055

I did not include any of the above mentioned missing libraries in my program

You technically did. By including Python.h, you effectively include all the headers it is including and depending on. If those are not there, then your code cannot compile. You can find more details on how to properly build around CPython into the Introduction Guide.

Upvotes: 1

Related Questions