Comments (6)
Hi @BenDerPan,
The bindings should work on Windows (I haven't tried), nothing is Linux specific.
Are you sure your setup for pkg-config
is working ? Does this command works on you build environment pkg-config --cflags python3
?
from go-python3.
There is a problem though.
- Python doesn't support
mingw32-w64
toolchain; onlymsvc
toolchain is supported for Windows: https://bugs.python.org/issue4709 https://wiki.python.org/moin/WindowsCompilers - But Golang doesn't support
msvc
: golang/go#36283
Probably we can somehow build some parts using MSVC and other parts using migw32-w64, but I am not sure how can this be achieved.
In fact, the issue I bumped into when first tried to build with mingw-w64
: Python.h
header requires crypt.h
, which is missing in mingw headers.
There is a mingwpy project there which aims to support building python modules with mingw, but it is seemingly dead and doesn't mention any support for python>3.5.
from go-python3.
Same issure on MacOS by using go get -u github.com/DataDog/go-python3
. Python3 already installed by pkg.
from go-python3.
first of all thanks a lot for this great project 🙏
can this work on windows
this go module works fine for me so far on Windows 10. However, I don't use mingw. This is what I do for Python 3.7 x64:
- go to the Python 3.7.7 downloads page and download the
Windows x86-64 embeddable zip file
(direct link) and extract it to i.e.c:\dist
(this will become the build output dir for your app and you will need to bundle these files with your app) - obtain the
include
dir from a regular Python 3.7.7 x64 installation (direct link regular installer) and put it somewhere (i.e. toc:\py\include
) - install TDM GCC (i.e. to
c:\tdm-gcc
) - install pkgconfig (easiest way I find is with the chocolatey package manager:
choco install pkgconfiglite
) - in your project, create a
pkg-config\python3.pc
file with these paths
prefix=C:/dist
exec_prefix=${prefix}
libdir=${exec_prefix}
includedir=C:/py/include
Name: Python
Description: Python library embedded
Requires:
Version: 3.7
Libs: -L${libdir} -lpython37 -lpthread -lm
Cflags: -I${includedir} -DMS_WIN64
in a cmd
shell navigate to your project root and set the environment:
set PATH=c:\dist;c:\tdm-gcc\bin;%PATH%
set PKG_CONFIG_PATH=%cd%\pkg-config
now we can build our app:
go build -o c:\dist
and run it (should work from any shell, i.e. the above env vars don't need to be set for running):
c:\dist\myapp.exe
One more note: If you accidentally compile against the wrong Python binaries the go build cache can be "dirty" (happened to me a couple of times). In that case rename/delete the folder that go env GOCACHE
shows.
from go-python3.
first of all thanks a lot for this great project 🙏
can this work on windows
this go module works fine for me so far on Windows 10. However, I don't use mingw. This is what I do for Python 3.7 x64:
- go to the Python 3.7.7 downloads page and download the
Windows x86-64 embeddable zip file
(direct link) and extract it to i.e.c:\dist
(this will become the build output dir for your app and you will need to bundle these files with your app)- obtain the
include
dir from a regular Python 3.7.7 x64 installation (direct link regular installer) and put it somewhere (i.e. toc:\py\include
)- install TDM GCC (i.e. to
c:\tdm-gcc
)- install pkgconfig (easiest way I find is with the chocolatey package manager:
choco install pkgconfiglite
)- in your project, create a
pkg-config\python3.pc
file with these pathsprefix=C:/dist exec_prefix=${prefix} libdir=${exec_prefix} includedir=C:/py/include Name: Python Description: Python library embedded Requires: Version: 3.7 Libs: -L${libdir} -lpython37 -lpthread -lm Cflags: -I${includedir} -DMS_WIN64
in a
cmd
shell navigate to your project root and set the environment:set PATH=c:\dist;c:\tdm-gcc\bin;%PATH% set PKG_CONFIG_PATH=%cd%\pkg-config
now we can build our app:
go build -o c:\dist
and run it (should work from any shell, i.e. the above env vars don't need to be set for running):
c:\dist\myapp.exe
One more note: If you accidentally compile against the wrong Python binaries the go build cache can be "dirty" (happened to me a couple of times). In that case rename/delete the folder that
go env GOCACHE
shows.
hello i'm new to golang i tried to use your instruction i was able to go get the package and compile but when running i get this
Exception 0xc0000005 0x0 0x10 0x7ffe1214f90d
PC=0x7ffe1214f90d
runtime: unknown pc 0x7ffe1214f90d
stack: frame={sp:0xdcd63ffaa0, fp:0x0} stack=[0x0,0xdcd63ffbe0)
000000dcd63ff9a0: 0000000000000008 00007ffe121691bb
000000dcd63ff9b0: 0000024540f90030 00007ffe1230a238
000000dcd63ff9c0: 0000000000000000 0000000000000000
000000dcd63ff9d0: 0000000000000004 0000000000000000
000000dcd63ff9e0: 0000000000000010 0000000000000000
000000dcd63ff9f0: 0000000000000001 0000000000000000
000000dcd63ffa00: 000002451bb20000 00007ffe6a7090cc
000000dcd63ffa10: 0000000000000000 0000024540f90060
000000dcd63ffa20: 0000007f00000001 0000000000000008
000000dcd63ffa30: 0000000000000008 0000000000000008
000000dcd63ffa40: 000000000000007f 0000000000000000
000000dcd63ffa50: 0000000000000000 00007ffe1230a240
000000dcd63ffa60: 00007ffe68ad0000 0000000000000000
000000dcd63ffa70: 000000000000000b 0000000000000001
000000dcd63ffa80: 0000000000000000 000002451bb26cf0
000000dcd63ffa90: 0000000000000000 ffffffffffffffff
000000dcd63ffaa0: <0000000000000025 00007ff7cc9174b8
000000dcd63ffab0: 00007ff7cc8fb920 00007ff7cc9911e0
000000dcd63ffac0: 0000024540f90030 00007ffe12189fd0
000000dcd63ffad0: 00007ffe1230a240 00007ffe1230a238
000000dcd63ffae0: 0000000000000000 0000000000000000
000000dcd63ffaf0: 000002451bb26cf0 00007ffe12175710
000000dcd63ffb00: 0000000000000000 00007ffe68c0c750
000000dcd63ffb10: 0000000000000000 0000000000000004
000000dcd63ffb20: 0000024540f518b8 0000000000000000
000000dcd63ffb30: 000000c000110000 00007ff7cc8c5caf
000000dcd63ffb40: 000000c00010ff20 0000000000000004
000000dcd63ffb50: 00007ff7cc86e4cd <runtime.wakep+109> 0000024540f518c8
000000dcd63ffb60: 000000c00010ff20 00007ff7cc9911e0
000000dcd63ffb70: 000000c00010ff20 00007ff7cc896753 <runtime.asmcgocall+115>
000000dcd63ffb80: 00007ff7cc9174f8 0000000000000010
000000dcd63ffb90: 00007ff7cc8f9b80 00007ff7cc8f9b80
runtime: unknown pc 0x7ffe1214f90d
stack: frame={sp:0xdcd63ffaa0, fp:0x0} stack=[0x0,0xdcd63ffbe0)
000000dcd63ff9a0: 0000000000000008 00007ffe121691bb
000000dcd63ff9b0: 0000024540f90030 00007ffe1230a238
000000dcd63ff9c0: 0000000000000000 0000000000000000
000000dcd63ff9d0: 0000000000000004 0000000000000000
000000dcd63ff9e0: 0000000000000010 0000000000000000
000000dcd63ff9f0: 0000000000000001 0000000000000000
000000dcd63ffa00: 000002451bb20000 00007ffe6a7090cc
000000dcd63ffa10: 0000000000000000 0000024540f90060
000000dcd63ffa20: 0000007f00000001 0000000000000008
000000dcd63ffa30: 0000000000000008 0000000000000008
000000dcd63ffa40: 000000000000007f 0000000000000000
000000dcd63ffa50: 0000000000000000 00007ffe1230a240
000000dcd63ffa60: 00007ffe68ad0000 0000000000000000
000000dcd63ffa70: 000000000000000b 0000000000000001
000000dcd63ffa80: 0000000000000000 000002451bb26cf0
000000dcd63ffa90: 0000000000000000 ffffffffffffffff
000000dcd63ffaa0: <0000000000000025 00007ff7cc9174b8
000000dcd63ffab0: 00007ff7cc8fb920 00007ff7cc9911e0
000000dcd63ffac0: 0000024540f90030 00007ffe12189fd0
000000dcd63ffad0: 00007ffe1230a240 00007ffe1230a238
000000dcd63ffae0: 0000000000000000 0000000000000000
000000dcd63ffaf0: 000002451bb26cf0 00007ffe12175710
000000dcd63ffb00: 0000000000000000 00007ffe68c0c750
000000dcd63ffb10: 0000000000000000 0000000000000004
000000dcd63ffb20: 0000024540f518b8 0000000000000000
000000dcd63ffb30: 000000c000110000 00007ff7cc8c5caf
000000dcd63ffb40: 000000c00010ff20 0000000000000004
000000dcd63ffb50: 00007ff7cc86e4cd <runtime.wakep+109> 0000024540f518c8
000000dcd63ffb60: 000000c00010ff20 00007ff7cc9911e0
000000dcd63ffb70: 000000c00010ff20 00007ff7cc896753 <runtime.asmcgocall+115>
000000dcd63ffb80: 00007ff7cc9174f8 0000000000000010
000000dcd63ffb90: 00007ff7cc8f9b80 00007ff7cc8f9b80
goroutine 1 [syscall]:
github.com/DataDog/go-python3._Cfunc_PyRun_SimpleStringFlags(0x2451bb26cf0, 0x0, 0x24500000000)
_cgo_gotypes.go:4695 +0x4b
github.com/DataDog/go-python3.PyRun_SimpleString(0x7ff7cc90e71e, 0x3, 0x0)
C:/Users/rbert/go/pkg/mod/github.com/!data!dog/[email protected]/high_level_layer.go:66 +0x93
main.main()
D:/!-criss/main.go:9 +0x3d
rax 0x0
rbx 0x24540f90030
rcx 0xdcd63ffa10
rdi 0x2451bb26cf0
rsi 0x7ff7cc9911e0
rbp 0xc00010fee0
rsp 0xdcd63ffaa0
r8 0x24540f90060
r9 0x24540f90000
r10 0xfc0
r11 0x246
r12 0x7ff7cc8fb920
r13 0x7ff7cc9174b8
r14 0x25
r15 0xffffffffffffffff
rip 0x7ffe1214f90d
rflags 0x10206
cs 0x33
fs 0x53
gs 0x2b
from go-python3.
i was able to go get the package and compile but when running i get this
@equisde I don't know what's the problem you're seeing, but I've just created a quick github actions demo project that builds a simple Windows executable with go-python3
. If you like you can fork it, run it on your github account and compare it with your setup. Hope this helps.
from go-python3.
Related Issues (20)
- python3.PyImport_ImportModule(name) will emit a fatal error when called the second time. HOT 5
- How do I create an Object HOT 2
- fatal error: Python.h: No such file or directory #include "Python.h" HOT 4
- get PyObject's refcount
- Error: C.PyEval_ReInitThreads
- could not determine kind of name for C.PyImport_GetModule HOT 2
- How to stop or terminate python execution? HOT 1
- Hi, How to capture function return when use python3.PyRun_AnyFile HOT 2
- could not determine kind of name for C.PyDict_ClearFreeList HOT 16
- PyEval_ReInitThreads removed since python 3.8 HOT 2
- build error on debian HOT 6
- Undefined reference to 'Py_True' HOT 4
- No module named xxx problem ,when the xxx is a so file .. HOT 2
- How could I Pass parameters from the Go side to the python file? HOT 2
- run on windows HOT 3
- SyntaxError: invalid syntax (uuid.py, line 138) HOT 1
- PyList_Insert and PyList_Append functions has an extra b HOT 2
- Goroutine calls Python but deadlocks HOT 2
- how can i use tensorflow with library HOT 2
- How do I create a Python bytes object HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-python3.