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
- ERROR: freetype2 not found using pkg-configError
- pkg-config
- Vue安裝依賴報錯:checking for Python executable "python" in the PATHVuePython
- go tool compile 報錯 could not import sync (file not found)GoCompileImport
- 編譯ffmpeg遇到ERROR: x265 not found using pkg-config解決方法編譯Error
- More than one file was found with OS independent path
- pkg-config 在windows 上面的安裝。Windows
- React Native 報錯 'config.h' file not foundReact Native
- tar (child): bzip2: Cannot exec: No such file or directory 報錯
- PHP-fpm Linux 環境使用 exec 函式呼叫 FFmpeg,報錯 FFmpeg: command not found 的解決方法PHPLinux函式
- 小程式錯誤:Component is not found in path
- A valid provisioning profile for this executable was not found.
- react-native install 報錯 No git binary found in $PATH解決方法ReactGit
- 【ASM】Oracle RAC css啟動報錯"Duplicate voting file found"ASMOracleCSS
- python virtualenv報錯-bash: virtualenv: command not foundPython
- 呼叫torchtext報錯OSError: libtorch_cpu.so: cannot open shared object file: No such file or directoryErrorObject
- 呼叫https介面時報錯:PKIX path building failed 的問題HTTPUIAI
- 整合 Python標準庫之 Path/File 類Python
- jsp錯誤: "javax.servlet.http.HttpServlet" was not found on the Java Build PathJSJavaServletHTTPUI
- Flutter在iOS裝置執行報錯fatal error: 'Flutter/Flutter.h' file not foundFlutteriOSError
- gorm忽略報錯: record not foundGoORM
- npm install報錯not found: python2的結局方法NPMPython
- 解決 If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configUbuntuGTK2dev
- scp 報錯 not a regular file
- Newline required at end of file but not foundUI
- CANNOT LINK EXECUTABLE "test_aidl_hal": library "android.hardware.hello-V1-ndk.so" not found: needed by main executableAIAndroid
- python execPython
- 使用URLClassLoader報錯not class found exceptionException
- 【linux報錯】-bash: xhost: command not foundLinux
- python 3呼叫paramiko模組報錯AttributeError: modulePythonError
- mongodb錯誤解決辦法-bash: ./mongod: cannot execute binary file: Exec format errorMongoDBORMError
- mysql RSA private key file not foundMySql
- 【maven】Maven報錯 zip END header not foundMavenHeader
- Jenkins 執行 selenium 自動化測試指令碼,呼叫 webdriver 時報錯:[Errno 8] Exec format error:Jenkins指令碼WebORMError
- querydsl報錯: Attempt to recreate a file for type
- 頁面報錯 No input file specified