Kotlin / kotlin-numpy

Kotlin bindings for NumPy
Apache License 2.0
316 stars 11 forks source link

UnsatisfiedLinkError on Mac #7

Open alannnna opened 4 years ago

alannnna commented 4 years ago

On version 0.1.3 on Mac I'm getting the following error 😬 :

java.lang.UnsatisfiedLinkError: org.jetbrains.numkt.Interpreter.callFunc$kotlin_numpy([Ljava/lang/String;[Ljava/lang/Object;Ljava/util/Map;)Lorg/jetbrains/numkt/core/KtNDArray;
        at org.jetbrains.numkt.Interpreter.callFunc$kotlin_numpy(Native Method)
        at org.jetbrains.numkt.UtilsKt.callFunc(Utils.kt:38)
        at org.jetbrains.numkt.UtilsKt.callFunc$default(Utils.kt:36)
        at myCode.matmul(myCode.kt:42)

Unfortunately I can't replicate this in my clean skeleton project, because there it appears the python setup is failing: java.lang.Exception: "Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/x9/sm6f5rgx4y9cqlcv6wxttvzjn76hsr/T/pip-install-knc9um2g/ktnumpy/" when executing the command: python -m pip install ktnumpy

I'll be switching to Anaconda in the meantime while exploring this. Thanks for all the quick responses.

devcrocod commented 4 years ago

Run in terminal python -m pip install ktnumpy to get a detail error and send it, please.

I have not updated the readme file yet. On version 0.1.3 pypi is used to distribute the native library to support python not from anaconda. When installing from pypi, the library is built and linked with libpython, but this will require the c compiler. On Mac Os, you can install and update Xcode to get clang or any other way to install compiler.

alannnna commented 4 years ago

With ktnumpy installed via pip, all is working! Thank you!

devcrocod commented 4 years ago

It's perfectly.

It bothers me that when you first started with version 0.1.3, you got the error. When executing python -m pip install ktnumpy command, did you receive a confirmation request from pip?

alannnna commented 4 years ago

I don't believe I did, but I don't remember for sure. Happy to test out some commands on my machine if it helps!

devcrocod commented 4 years ago

If it's not difficult for you, remove the ktnumpy package - pip uninstall ktnumpy (this will not lead to anything bad) and run your code. If there is an error, please report me and install ktnumpy back - pip install ktnumpy.

This bothers me because kotlin-numpy has to install and update the ktnumpy package itself.

amolgupta commented 4 years ago

I got the same error. Below is the stacktrace

java.lang.UnsatisfiedLinkError: org.jetbrains.numkt.Interpreter.closePython()V
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:95)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:40)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)
kotlin.script.experimental.jvmhost.repl.JvmReplEvaluator$eval$$inlined$write$lambda$2.invokeSuspend(legacyReplEvaluation.kt:57)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:80)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:54)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
kotlin.script.experimental.jvmhost.repl.JvmReplEvaluator.eval(legacyReplEvaluation.kt:57)
org.jetbrains.kotlin.cli.common.repl.ReplEvalAction$DefaultImpls.eval$default(ReplApi.kt:123)
org.jetbrains.kotlin.jupyter.ReplForJupyter.doEval(repl.kt:266)
org.jetbrains.kotlin.jupyter.ReplForJupyter.eval(repl.kt:199)
org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:71)
org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt)
org.jetbrains.kotlin.jupyter.ProtocolKt.evalWithIO(protocol.kt:201)
org.jetbrains.kotlin.jupyter.ProtocolKt.shellMessagesHandler(protocol.kt:70)
org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:104)
org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:59)
amolgupta commented 4 years ago

And after installing kynumpy dependency I get

java.lang.UnsatisfiedLinkError: org.jetbrains.numkt.Interpreter.callFunc$kotlin_numpy([Ljava/lang/String;[Ljava/lang/Object;Ljava/util/Map;)Lorg/jetbrains/numkt/core/KtNDArray;
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:95)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:40)
kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)
kotlin.script.experimental.jvmhost.repl.JvmReplEvaluator$eval$$inlined$write$lambda$2.invokeSuspend(legacyReplEvaluation.kt:57)
kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:238)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.kt:116)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:80)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:54)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:36)
org.jetbrains.kotlin.mainKts.relocatedDeps.kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
kotlin.script.experimental.jvmhost.repl.JvmReplEvaluator.eval(legacyReplEvaluation.kt:57)
org.jetbrains.kotlin.cli.common.repl.ReplEvalAction$DefaultImpls.eval$default(ReplApi.kt:123)
org.jetbrains.kotlin.jupyter.ReplForJupyter.doEval(repl.kt:266)
org.jetbrains.kotlin.jupyter.ReplForJupyter.eval(repl.kt:199)
org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:71)
org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt)
org.jetbrains.kotlin.jupyter.ProtocolKt.evalWithIO(protocol.kt:201)
org.jetbrains.kotlin.jupyter.ProtocolKt.shellMessagesHandler(protocol.kt:70)
org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:104)
org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:59)
devcrocod commented 4 years ago

@amolgupta Library couldn't load the native library.

Please write your environments. What version of library are you using? What is the operating system? Which python? kotlin_kernel version? To check whether the native library is installed, enter the following command in the terminal: pip show ktnumpy.