go调用python报错pkg-config: exec: "pkg-config": executable file not found in %PATH%

Go调用Python:解决pkg-config错误
在Windows环境中尝试使用go-get和pkg-config时遇到'pkg-config: exec: "pkg-config": executable file not found in %PATH%'的错误。转到Linux系统后,通过编辑cgoflags.go、安装python-all-dev包和解决python-2.7.pc文件缺失问题,成功解决该错误。最终在Linux上使用go-get获取go-python库,并运行官方示例,一切正常。

我开始是在windows环境下直接go get github.com/sbinet/go-python
会报错pkg-config: exec: “pkg-config”: executable file not found in %PATH%

后来还是算了,直接在我的云服务器上面去跑了,windows系统的坑略多,于是放弃windows,直接去了linux系统进行如下操作:

官方文档写的是

If go get + pkg-config failed:
$ cd go-python
$ edit cgoflags.go
$make VERBOSE=1
Note: you’ll need the proper header and python
development environment. On Debian, you’ll need to install the
python-all-dev package

最后总结报这个错是/usr/lib/pkgconfig少了python-2.7.pc文件以及python-dev环境
在/usr/lib/pkgconfig新建python-2.7.pc:

prefix=/usr
exec_prefix=/usr
libdir=/usr/lib64
includedir=/usr/include

Name: Python
Description: Python library
Requires: 
Version: 2.7
Libs.private: -lpthread -ldl  -lutil
Libs: -L${libdir} -lpython2.7
Cflags: -I${includedir}/python2.7 

直接下载python-dev会有依赖关系的问题,要通过aptitude来下载

sudo apt-get install aptitude 
sudo aptitude install py
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值