oracle / graalpython

GraalPy – A high-performance embeddable Python 3 runtime for Java
https://www.graalvm.org/python/
Other
1.24k stars 108 forks source link

Embedding run python with Polyglot Application #266

Closed young-yan closed 2 years ago

young-yan commented 2 years ago

it`s not work when Embedding run python with Polyglot Application, i have install numpy with graalpython

from numpy import *

print(eye(4))

2022-05-16 10:35:45,732 [http-nio-8090-exec-7] [FunctionRouter.java:110] [ERROR FunctionRouter] - handleFunc handle Throwable@error: req:FuncReqContext(appId=48, funcCode=test-py-func, reqJson=test-doc, online=true) org.graalvm.polyglot.PolyglotException: ModuleNotFoundError: No module named 'numpy' at org.graalvm.sdk/org.graalvm.polyglot.Context.eval(Context.java:405) at com.yy.faas.invoker.js.impl.graa.GraaPyInvoker.funcInvoke(GraaPyInvoker.java:34) at com.yy.faas.func.router.FunctionRouter.handleFunc(FunctionRouter.java:94) at com.yy.faas.controller.FuncController.function(FuncController.java:79) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568)

msimacek commented 2 years ago

Hi @young-yan, you need to set python.Executable context option to the path of the python executable of the virtualenv where you installed numpy (like my_virtualenv/bin/python)