Open Ryan007 opened 7 years ago
how did you install python?
AFAIK, centos-6
had python-2.6.
here is what I did in a docker container:
#> docker run -it --rm centos:6 bash
$> yum update -y
$> yum install -y centos-release-SCL
$> yum install -y python27 python27-python-devel
$> yum install -y gcc git
$> export PKG_CONFIG_PATH=/opt/rh/python27/root/usr/lib64/pkgconfig:$PKG_CONFIG_PATH
$> cd /
$> curl -O -L https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
$> mkdir /goroot
$> cd /goroot
$> tar -zxf ../go1.7.4.linux-amd64.tar.gz
$> export GOROOT=`pwd`/go
$> export PATH=$GOROOT/bin:$PATH
$> cd /
$> mkdir /gopath
$> cd /gopath
$> export GOPATH=`pwd`
$> go get -d github.com/sbinet/go-python
$> cd $GOPATH/src/github.com/sbinet/go-python
$> make install
go get -compiler="gc" .
$> echo $?
0
FIRST OF ALL THANK YOU
install by source code and complied, it works fine.
ok. so, what is the output of:
$> pkg-config --cflags --libs python-2.7
-I/usr/include/python2.7 -lpython2.7
?
(the linker error would seem to indicate that you are missing -lm
and -ldl
)
$> export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig
PKG_CONFIG_PATH should set to cgo. pkgconfig will give proper link options to build math lib.
I spent 2 days figuring out why ubuntu failed to make go-python.
in VSCode you can build and run by editing launch.json
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {
"PKG_CONFIG_PATH":"$PKG_CONFIG_PATH:/usr/lib/x86_64-linux-gnu/pkgconfig"
},
"args": []
}
]
}
$> whereis pkgconfig pkgconfig: /usr/lib/x86_64-linux-gnu/pkgconfig /usr/lib/pkgconfig /usr/local/lib/pkgconfig /usr/share/pkgconfig
and find out python3.pc in located pkgconfig folders usr/lib/x86_64-linux-gnu/pkgconfig$> ls expat.pc geoclue-2.0.pc libssl.pc ncursesw.pc python-3.7m.pc sqlite3.pc uuid.pc xorg-wacom.pc fontconfig.pc grilo-plugins-0.3.pc libxcrypt.pc openssl.pc python-3.7.pc tcl8.6.pc x11.pc xrender.pc form.pc ice.pc menu.pc panel.pc python-3.8-embed.pc tcl.pc xau.pc xscrnsaver.pc formw.pc libcrypto.pc menuw.pc panelw.pc python-3.8.pc tic.pc xcb.pc xt.pc freetype2.pc libcrypt.pc ncurses++.pc pthread-stubs.pc python3-embed.pc tinfo.pc xdmcp.pc zlib.pc gcalc-2.pc libpng16.pc ncurses.pc python-2.7.pc python3.pc
in cgoflags_unix.go file
// +build !windows
package python
// #cgo pkg-config: python-2.7 // #include "go-python.h" import "C"
cgo pkg-config: python-2.7 --> pkg-config should know to find python-2.7.pc file path
sudo apt-get update -y sudo apt-get install -y pkg-config
if don't install pkg-config , install pkg-config.
when i run
make install
, it failed is that my python version wrong, please help me?base info: centos6.2 x64 python-2.7.13 go version go1.7.4 linux/amd64