linker errors - Scala scalapy

When I try to run the example line: val len = py.Dynamic.global.len(List(1, 2, 3).toPythonProxy), I get the following error:

[info] running (fork) Main
[error] Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void me.shadaj.scalapy.interpreter.CPythonAPIInterface.Py_Initialize()'
[error]     at me.shadaj.scalapy.interpreter.CPythonAPIInterface.Py_Initialize(Native Method)
[error]     at me.shadaj.scalapy.interpreter.CPythonInterpreter$.<init>(CPythonInterpreter.scala:9)
[error]     at me.shadaj.scalapy.interpreter.CPythonInterpreter$.<clinit>(CPythonInterpreter.scala)
[error]     at me.shadaj.scalapy.py.package$.<init>(package.scala:15)
[error]     at me.shadaj.scalapy.py.package$.<clinit>(package.scala)
[error]     at Main$.main(Main.scala:6)
[error]     at Main.main(Main.scala)
[error] Nonzero exit code returned from runner: 1
[error] (Compile / run) Nonzero exit code returned from runner: 1
[error] Total time: 0 s, completed Dec 27, 2020 8:00:49 PM

I also get an error when trying with scala native:

[error] cannot link: @me.shadaj.scalapy.py.Any
[error] cannot link: @me.shadaj.scalapy.py.Any::as_me.shadaj.scalapy.readwrite.Reader_java.lang.Object
[error] cannot link: @me.shadaj.scalapy.py.Dynamic
[error] cannot link: @me.shadaj.scalapy.py.Dynamic$global$
[error] cannot link: @me.shadaj.scalapy.py.Dynamic$global$::applyDynamic_java.lang.String_scala.collection.Seq_me.shadaj.scalapy.py.Dynamic
[error] cannot link: @me.shadaj.scalapy.py.package$
[error] cannot link: @me.shadaj.scalapy.py.package$::SeqConverters_java.lang.Object_scala.Function1_me.shadaj.scalapy.py.package$SeqConverters
[error] cannot link: @me.shadaj.scalapy.py.package$SeqConverters
[error] cannot link: @me.shadaj.scalapy.py.package$SeqConverters::toPythonProxy_me.shadaj.scalapy.readwrite.Writer_me.shadaj.scalapy.py.Any
[error] cannot link: @me.shadaj.scalapy.readwrite.Reader
[error] cannot link: @me.shadaj.scalapy.readwrite.Reader$
[error] cannot link: @me.shadaj.scalapy.readwrite.Reader$::intReader_me.shadaj.scalapy.readwrite.Reader
[error] cannot link: @me.shadaj.scalapy.readwrite.Writer
[error] cannot link: @me.shadaj.scalapy.readwrite.Writer$
[error] cannot link: @me.shadaj.scalapy.readwrite.Writer$::intWriter_me.shadaj.scalapy.readwrite.Writer
[error] unable to link
[error] (Compile / nativeLink) unable to link
Asked Oct 05 '21 11:10
avatar joprice
joprice

4 Answer:

I'm not able to reproduce this error when building locally. Could you ensure that you've added the Scala Native version of ScalaPy (libraryDependencies += "me.shadaj" %%% "scalapy-core" % "0.4.0") and are using Scala Native 0.4.0-M2?

1
Answered Dec 28 '20 at 20:07
avatar  of shadaj
shadaj

Actually I was on an 0.3.8. When I try 0.4.0-M2, I get a different error:

[error] (Compile / nativeLink) java.util.NoSuchElementException: key not found: Top(me.shadaj.scalapy.py.package$)
1
Answered Dec 29 '20 at 00:19
avatar  of joprice
joprice

@joprice could you try with the latest master? The Scala Native build has been updated to use 0.4.0

1
Answered Jan 28 '21 at 23:14
avatar  of shadaj
shadaj

Closing since there hasn't been much activity on this and the type of crashes reported should be fixed with Scala Native 0.4.x.

1
Answered Mar 11 '21 at 22:43
avatar  of shadaj
shadaj