Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Undefined reference to 'Py_True' #41

Closed
Mingmingchina1996 opened this issue Apr 22, 2021 · 4 comments
Closed

Undefined reference to 'Py_True' #41

Mingmingchina1996 opened this issue Apr 22, 2021 · 4 comments

Comments

@Mingmingchina1996
Copy link

Describe what happened:
I got the following errors when I use 'go get github.com/DataDog/go-python3' to install this package on Ubuntu:
/tmp/go-build990175588/github.com/DataDog/go-python3/_obj/_cgo_main.o:(.data.rel+0x0):undefined reference to 'Py_True'
/tmp/go-build990175588/github.com/DataDog/go-python3/_obj/_cgo_main.o:(.data.rel+0x8):undefined reference to 'Py_None'
/tmp/go-build990175588/github.com/DataDog/go-python3/_obj/_cgo_main.o:(.data.rel+0x10):undefined reference to 'Py_False'

@christian-korneck
Copy link
Contributor

christian-korneck commented Apr 22, 2021

@Mingmingchina1996 are you using Python3.7 (which is the only one supported python version of go-python3)? Depending on the Ubuntu version you might need to get a different Python version than from the official OS packages. Here's an example for doing that on Debian, which should be roughly similar to Ubuntu.

@Mingmingchina1996
Copy link
Author

@Mingmingchina1996 are you using Python3.7 (which is the only one supported python version of go-python3)? Depending on the Ubuntu version you might need to get a different Python version than from the official OS packages. Here's an example for doing that on Debian, which should be roughly similar to Ubuntu.

I am using python3.7.10. maybe I should try install it with docker

@christian-korneck
Copy link
Contributor

you don't need docker, this works for me on Ubuntu 20.04:

cd $HOME
sudo su
apt-get -y update && apt-get -y install curl build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev git curl pkg-config gcc golang
curl https://www.python.org/ftp/python/3.7.10/Python-3.7.10.tgz -o python.tgz && tar xf python.tgz
cd Python-3.7.10
./configure --enable-shared --prefix=/opt/py
make -j `nproc`
make install
echo /opt/py/lib > /etc/ld.so.conf.d/py.conf && ldconfig
export PKG_CONFIG_PATH=/opt/py/lib/pkgconfig
cd $HOME
mkdir hello
cd hello
curl -L https://raw.githubusercontent.com/christian-korneck/Dockerfiles/master/debian-go-python3-demo/hello/main.go -o main.go
go mod init hello
go mod tidy
go get .
go build -o /opt/hello/bin/hello .

and then run it:

$ /opt/hello/bin/hello
hello from python in go

@Mingmingchina1996
Copy link
Author

you don't need docker, this works for me on Ubuntu 20.04:

cd $HOME
sudo su
apt-get -y update && apt-get -y install curl build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev git curl pkg-config gcc golang
curl https://www.python.org/ftp/python/3.7.10/Python-3.7.10.tgz -o python.tgz && tar xf python.tgz
cd Python-3.7.10
./configure --enable-shared --prefix=/opt/py
make -j `nproc`
make install
echo /opt/py/lib > /etc/ld.so.conf.d/py.conf && ldconfig
export PKG_CONFIG_PATH=/opt/py/lib/pkgconfig
cd $HOME
mkdir hello
cd hello
curl -L https://raw.githubusercontent.com/christian-korneck/Dockerfiles/master/debian-go-python3-demo/hello/main.go -o main.go
go mod init hello
go mod tidy
go get .
go build -o /opt/hello/bin/hello .

and then run it:

$ /opt/hello/bin/hello
hello from python in go

With your instruction, I have solved this issue. Thank you very much

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants