1

I am hitting the below error when I try compiling the go code from Windows (using msys terminal). (I have used go-python from sbinet for one of my use case which needed python from GO.)

# github.com/sbinet/go-python
In file included from C:\Users\BHARATU\go\pkg\mod\github.com\sbinet\go-python@v0.1.0\capi.go:3:
./go-python.h:4:10: fatal error: Python.h: No such file or directory
 #include "Python.h"
          ^~~~~~~~~~
compilation terminated.

I have set the --cflags for the gcc too.

$ python
Python 3.8.5 (default, Aug 27 2020, 21:53:06)
[GCC 9.3.0] on msys
Type "help", "copyright", "credits" or "license" for more information.
>>>

$ which python
/usr/bin/python

$ /usr/bin/pkg-config.exe --cflags --libs python
-I/usr/include/python3.8 -lcrypt -lintl -ldl -lpython3.8

The below command fails:

$ gcc -Wall -I/usr/include/python3.8 -lpython3.8 utilsmodule.c -o Utilc
gcc.exe: error: utilsmodule.c: No such file or directory

ReadMe.Md in https://github.com/sbinet/go-python says to change the cgoflags based on the OS type.

Below is the default snapshot from my env. What do I need to change here?

// +build windows

package python

    // #cgo 386   CFLAGS: -I C:/Python27/include
    // #cgo amd64 CFLAGS: -I C:/Python27-x64/include
    // #cgo amd64 CFLAGS: -D MS_WIN64
    // #cgo 386   LDFLAGS: -L C:/Python27/libs     -lpython27
    // #cgo amd64 LDFLAGS: -L C:/Python27-x64/libs -lpython27
    //
    // #include "go-python.h"
    import "C"
tripleee
  • 175,061
  • 34
  • 275
  • 318
Uday
  • 11
  • 1
  • The immediate problem is that `Python.h` is not installed. You should probably provide more details to explain what you are trying to do, but also focus on a single problem. See also the guidance for providing a [mre]. But if this is your first time trying to compile C code, you are probably in for a significant learning curve. – tripleee Sep 14 '21 at 11:12
  • New comer to this space .. bare with my Qs .. – Uday Sep 14 '21 at 12:13
  • how do i confirm that python.h is not installed ? I do see that module exists , $/usr/include/python3.8 $ ls -lrt pyt Python.h Python-ast.h pythonrun.h pythread.h pytime.h – Uday Sep 14 '21 at 12:16
  • You are probably confused between Windows and Unix-style directory names. `/usr/include` does not exist on regular Windows; do you mean something like `C:/mnt/usr/include` or whatever it's called on your machine? If you pass in the wrong path, of course the compiler can't find it. Perhaps see also [Difference between `./` and `~/`](https://stackoverflow.com/questions/31435921/difference-between-and/55342466) (though if you are unfamiliar with very basic computer concepts, probably give up and come back when you are older). – tripleee Sep 14 '21 at 12:19

0 Answers0