go呼叫python報錯pkg-config: exec: "pkg-config": executable file not found in %PATH%
我開始是在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 python-dev
最後下載go get github.com/sbinet/go-python,沒有問題
執行一個官方例子
package main
import "fmt"
import "github.com/sbinet/go-python"
func init() {
err := python.Initialize()
if err != nil {
panic(err.Error())
}
}
func main() {
gostr := "foo"
pystr := python.PyString_FromString(gostr)
str := python.PyString_AsString(pystr)
fmt.Println("hello [", str, "]")
}
執行
$ go run ./main.go
輸出
hello [ foo ]
相關文章
- Package libxml-2.0 was not found in the pkg-config search pathPackageXML
- fribidi not found using pkg-config
- Vue安裝依賴報錯:checking for Python executable "python" in the PATHVuePython
- ERROR: freetype2 not found using pkg-configError
- go tool compile 報錯 could not import sync (file not found)GoCompileImport
- pkg-config
- Linux命令pkg-configLinux
- More than one file was found with OS independent path
- tar (child): bzip2: Cannot exec: No such file or directory 報錯
- 編譯ffmpeg遇到ERROR: x265 not found using pkg-config解決方法編譯Error
- PHP-fpm Linux 環境使用 exec 函式呼叫 FFmpeg,報錯 FFmpeg: command not found 的解決方法PHPLinux函式
- pkg-config 在windows 上面的安裝。Windows
- React Native 報錯 'config.h' file not foundReact Native
- 小程式錯誤:Component is not found in path
- 自定義容器啟動指令碼報錯:exec user process caused "no such file or directory"指令碼
- 【ASM】Oracle RAC css啟動報錯"Duplicate voting file found"ASMOracleCSS
- JavaWeb:報錯資訊The superclass \"javax.servlet.http.HttpServlet\" was not found on the Java Build PathJavaWebServletHTTPUI
- <摘錄>簡述configure、pkg-config、pkg_config_path三者的關係
- python virtualenv報錯-bash: virtualenv: command not foundPython
- react-native install 報錯 No git binary found in $PATH解決方法ReactGit
- gorm忽略報錯: record not foundGoORM
- 呼叫torchtext報錯OSError: libtorch_cpu.so: cannot open shared object file: No such file or directoryErrorObject
- Flutter在iOS裝置執行報錯fatal error: 'Flutter/Flutter.h' file not foundFlutteriOSError
- MySQL 5.7啟動資料庫報錯'does not exist or is not executable'MySql資料庫
- 整合 Python標準庫之 Path/File 類Python
- Mysql啟動錯誤-server PID file could not be foundMySqlServer
- ***報錯Class 'Redis' not found in(原創)Redis
- npm install報錯not found: python2的結局方法NPMPython
- MysqL錯誤之_ERROR! MySQL server PID file could not be found!MySqlErrorServer
- jsp錯誤: "javax.servlet.http.HttpServlet" was not found on the Java Build PathJSJavaServletHTTPUI
- maven The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path錯誤MavenJavaServletHTTPUI
- Error 15: File not found for RedhatErrorRedhat
- 使用URLClassLoader報錯not class found exceptionException
- oracle 11.2.0.4 path 26925576 報錯Oracle
- mybatis 報錯: Invalid bound statement (not found)MyBatis
- python execPython
- python 3呼叫paramiko模組報錯AttributeError: modulePythonError
- 頁面報錯 No input file specified