Could not create a JVM using pyimagej - pyimagej

Hi I'm using pyimagej on macOS and I could not initialise imagej on Jupyter Notebook.
import imagej
ij = imagej.init()
And specifically, this is the error I got:
Failed to bootstrap the artifact.
Possible solutions:
Double check the endpoint for correctness (https://search.maven.org/).
Add needed repositories to ~/.jgorc [repositories] block (see README).
Try with an explicit version number (release metadata might be wrong).
Full Maven error output:
RuntimeError: Failed to create a JVM with the requested environment.

Related

Unable to run/debug robot tests in vscode - robocorp extensions installed

I have installed Robocorp Code as well as Robot Framework Language Server and have configured them. However, I am still having errors when trying to run the tests via the code lens options.
Repo - A webapi repo with a specific folder containing all tests. Lets call it regression.
RF - 4.1.3
Python - 3.8
This is what happens when I click on Run on the code lens for any of the tests -
`PS C:\git\xxxx\regression> C:; cd 'C:\git\xxxx\regression'; &
'C:\Users\xxxx\AppData\Local\Temp\rf-ls-run\run_env_00_smh5defr.bat'
'-u'
'c:\Users\xxxx.vscode\extensions\robocorp.robotframework-lsp-0.47.2\src\robotframework_debug_adapter\run_robot__main__.py'
'--port' '54331' '--no-debug' '--argumentfile'
'C:\git\xxxx\regression\args-local.txt' '--pythonpath'
'c:\git\xxxx\regression\common\lib' '--variable'
'EXECDIR:C:/git/xxxx/regression'
'--prerunmodifier=robotframework_debug_adapter.prerun_modifiers.FilteringTestsSuiteVisitor'
'c:\git\xxxx\regression\api\api_Test.robot'
[ ERROR ] Parsing'--pythonpath' failed: File or directory to execute does not exist.
However, the test starts if I remove the argumentfile parameter but it, of course, fails because its missing arguments from the file.
Do note that the folder specified in pythopath exists and has some python libraries needed for the tests.

How to debug unit test while developping a package in Julia

Say I develop a package with a limited set of dependencies (for example, LinearAlgebra).
In the Unit testing part, I might need additional dependencies (for instance, CSV to load a file). I can configure that in the Project.toml all good.
Now from there and in VS Code, how can I debug the Unit tests? I tried running the "runtests.jl" in the debugger; however, it unsurprisingly complains that the CSV package is unavailable.
I could add the CSV package (as a temporary solution), but I would prefer that the debugger run with the configuration for the unit testing; how can I achieve that?
As requested, here is how it can be reproduced (it is not quite minimal, but instead I used a commonly used package as it give confidence the package is not the problem). We will use DataFrames and try to execute the debugger for its unit tests.
Make a local version of DataFrames for the purpose of developing a feature in it. I execute dev DataFrames in a new REPL.
Select the correct environment (in .julia/dev/DataFrames) through the VS-code user interface.
Execute the "proper" unit testing by executing test DataFrames at the pkg prompt. Everything should go smoothly.
Try to execute the tests directly (open the runtests.jl and use the "Run" button in vs-code). I see some errors of the type:
LoadError: ArgumentError: Package CategoricalArrays not found in current path:
- Run `import Pkg; Pkg.add("CategoricalArrays")` to install the CategoricalArrays package.
which is consistent with CategoricalArrays being present in the [extras] section of the Project.toml but not present in the [deps].
Finally, instead of the "Run" command, execute the "Run and Debug". I encounter similar errors here is the first one:
Test Summary: | Pass Total
merge | 19 19
PASSED: index.jl
FAILED: dataframe.jl
LoadError: ArgumentError: Package DataStructures not found in current path:
- Run `import Pkg; Pkg.add("DataStructures")` to install the DataStructures package.
So I can't debug the code after the part requiring the extras packages.
After all that I delete this package with the command free DataFrames at the pkg prompt.
I see the same behavior in my package.
I'm not certain I understand your question, but I think you might be looking for the TestEnv package. It allows you to activate a temporary environment containing the [extras] dependencies. The discourse announcement contains a good description of the use cases.
Your runtest.jl file should contain all necessary imports to run tests.
Hence you are expected to have in your runtests.jl file lines such as:
using YourPackageName
using CSV
# the lines with tests now go here.
This is a standard in Julia package layout. For an example have a look at any mature Julia such as DataFrames.jl (https://github.com/JuliaData/DataFrames.jl/blob/main/test/runtests.jl).

Why can't I add a package (module) I created in Julia?

I am having trouble installing a module I created in Julia. I am running the Julia plugin under Visual Studio Code. If I run the file below with Ctrl+F5 I get a message
ERROR: LoadError: ArgumentError: Package Utils not found in current path:
- Run `import Pkg; Pkg.add("Utils")` to install the Utils package.
This is the file:
module demo
using Utils
greet() = print("Hello World!")
end # module
If I follow the advice on the error message I get another error message:
ERROR: LoadError: The following package names could not be resolved:
* Utils (not found in project, manifest or registry)
I also tried inserting this line:
import Pkg; Pkg.add(path="C:/Dropbox/Code/Julia/demo/src/Utils.jl")
and got this message (although the path definitely exists):
ERROR: LoadError: Path `C:/Dropbox/Code/Julia/demo/src/Utils.jl` does not exist.
The files demo.jl and Utils.jl are in C:\Dropbox\Code\Julia\demo\src\ and the demo project has been activated as can be seen in the REPL. The OS is Windows 10 Pro.
Any help will be greatly appreciated. Lots of time wasted trying to make this work.
Module and packages are not the same things. In short, packages are modules plus a set of metadata that make it easy for the package to be found and interact well with other packages. See here for a tutorial to write Julia packages:
https://syl1.gitbook.io/julia-language-a-concise-tutorial/language-core/11-developing-julia-packages
In your case, if you want to load a local module, just type include("fileWhereThereIsTheModule.jl") followed by a using Main.MyModule or using .MyModule. Note the dot... without it, Julia would indeed look for a package and to let it find your Demo or Util module you would have to either change an environmental variable or place your module file in certain predefined folders. Using include followed by the "absolute or relative position" of the module you don't have to do either.

Java Illegal Argument Exception thrown when opening NetLogo model in Jython

I am trying to control NetLogo's API using Jython 2.7.0 (on Java 1.8.0_131) running on OS X El Capitan (10.11.6) to run experiments. In trying to run the following code:
import site
site.addsitedir("/Users/nqe/NetLogo/NetLogo 6.0.1/Java/")
import org.nlogo.headless.HeadlessWorkspace as hw
workspace = hw.newInstance()
workspace.open("models/Sample Models/Earth Science/Fire.nlogo")
workspace.command("set density 62")
workspace.command("random-seed 0")
workspace.command("setup")
workspace.command("repeat 50 [ go ]")
print (workspace.report("burned-trees"))
workspace.dispose()
I get the following error:
at scala.Predef$.require(Predef.scala:264)
at org.nlogo.generate.PrimitiveCache$.read$1(PrimitiveCache.scala:22)
at org.nlogo.generate.PrimitiveCache$.$anonfun$getClassReader$1(PrimitiveCache.scala:26)
at scala.collection.mutable.AbstractMap.getOrElseUpdate(Map.scala:80)
at org.nlogo.generate.PrimitiveCache$.getClassReader(PrimitiveCache.scala:26)
at org.nlogo.generate.PeepholeSafeChecker.processClass(PeepholeSafeChecker.scala:49)
at org.nlogo.generate.PeepholeSafeChecker.isSafe(PeepholeSafeChecker.scala:42)
at org.nlogo.generate.Generator$InstructionGenerator.generateInstruction(Generator.scala:190)
at org.nlogo.generate.Generator$InstructionGenerator.generateBodyMethod(Generator.scala:124)
at org.nlogo.generate.Generator$InstructionGenerator.generate(Generator.scala:99)
at org.nlogo.generate.Generator.org$nlogo$generate$Generator$$recurse(Generator.scala:29)
at org.nlogo.generate.Generator.$anonfun$recurse$1(Generator.scala:31)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:193)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:193)
at org.nlogo.generate.Generator.org$nlogo$generate$Generator$$recurse(Generator.scala:31)
at org.nlogo.generate.Generator.$anonfun$generate$1(Generator.scala:25)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:193)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.mutable.ArrayOps$ofRef.map(ArrayOps.scala:193)
at org.nlogo.generate.Generator.generate(Generator.scala:25)
at org.nlogo.compile.CompilerMain$.assembleProcedure(CompilerMain.scala:79)
at org.nlogo.compile.CompilerMain$.$anonfun$compile$2(CompilerMain.scala:55)
at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)
at scala.collection.immutable.List.foreach(List.scala:378)
at scala.collection.TraversableLike.map$(TraversableLike.scala:234)
at scala.collection.immutable.List.map(List.scala:284)
at org.nlogo.compile.CompilerMain$.compile(CompilerMain.scala:55)
at org.nlogo.compile.Compiler.compileProgram(Compiler.scala:52)
at org.nlogo.headless.HeadlessModelOpener.openFromModel(HeadlessModelOpener.scala:54)
at org.nlogo.headless.HeadlessWorkspace.openModel(HeadlessWorkspace.scala:532)
at org.nlogo.headless.HeadlessWorkspace.open(HeadlessWorkspace.scala:499)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: requirement failed
In case the "import site" part is not clear, I did the following:
Create a jython script to write all .jar files in "/Users/nqe/NetLogo/NetLogo 6.0.1/Java/" to a .pth file.
I then placed this .pith file into said the .../Java/ directory with the .jar files.
This allows me to access all the .jar dependencies from sys.path when needing to the import various API features of NetLogo.
I can't figure out exactly what causes this error, for in running on python interactive mode, I was able to successfully create a new instance of NetLogo JVM using the hw.newInstance() command (I could see a Java icon pop up when running this code), and the open command threw the appropriate errors if I fail to specify a url, for example.
Because of this, I thought it might have something to do with my JVM not being configured properly, so I tried a few things.
First, I checked that I was able to actually run the java example of controlling NetLogo API in headless mode found here: https://github.com/NetLogo/NetLogo/wiki/Controlling-API. I was able to run the code given here using these commands:
javadir=/Users/nqe/NetLogo/ControlAPI/
netjardir=/Users/nqe/NetLogo/NetLogo\ 6.0.1/Java/netlogo-mac-app.jar
javaname=Example1
javac -cp "${javadir}":"${netjardir}" $javaname.java
java -cp "${javadir}":"${netjardir}" $javaname
without changing any JVM settings manually. Nevertheless, I went ahead and tried changing things in my JVM settings when running the jython code such as the path to docs and extensions, but in particular, to the ./lib directory. Unfortunately, specifying the following JVM setting:
-Djava.library.path=~/JRE/Contents/Home/jre/lib/
does nothing to help the cause. Note that the ~ here is short for being in the NetLogo 6.0.1 directory and that this was the only lib directory I could find.
Finally, I discord this: when I try to run the above jython script when only specifying the path to netlogo-mac-app.jar, I AM NOT ABLE TO IMPORT the headless class stuff. Hence, the compilation/ running of the java while specifying only this one .jar classpath could possibly be somehow accessing some useful meta-data necessary for NetLogo to work (I don't know if this is possible with my level of Java background).
Upon thinking this, I found a NetLogo.cfg file in ~/NetLogo 6.0.1.app/Contents/Java/ that contains the following info:
[Application]
app.name=NetLogo
app.mainjar=netlogo-mac-app.jar
app.version=6.0.1
app.preferences.id=org/nlogo/app
app.mainclass=org/nlogo/app/MacApplication
app.classpath=$APPDIR/../../Java/args4j-2.0.12.jar:$APPDIR/../../Java/asm-5.0.3.jar:$APPDIR/../../Java/asm-5.0.3.jar:$APPDIR/../../Java/asm-all-5.0.4.jar:$APPDIR/../../Java/asm-all-5.0.4.jar:$APPDIR/../../Java/asm-analysis-5.0.3.jar:$APPDIR/../../Java/asm-analysis-5.0.3.jar:$APPDIR/../../Java/asm-tree-5.0.3.jar:$APPDIR/../../Java/asm-tree-5.0.3.jar:$APPDIR/../../Java/asm-util-5.0.3.jar:$APPDIR/../../Java/asm-util-5.0.3.jar:$APPDIR/../../Java/behaviorsearch.jar:$APPDIR/../../Java/commons-codec-1.10.jar:$APPDIR/../../Java/commons-codec-1.10.jar:$APPDIR/../../Java/commons-logging-1.1.1.jar:$APPDIR/../../Java/commons-logging-1.1.1.jar:$APPDIR/../../Java/gluegen-rt-2.3.2.jar:$APPDIR/../../Java/gluegen-rt-2.3.2.jar:$APPDIR/../../Java/httpclient-4.2.jar:$APPDIR/../../Java/httpclient-4.2.jar:$APPDIR/../../Java/httpcore-4.2.jar:$APPDIR/../../Java/httpcore-4.2.jar:$APPDIR/../../Java/httpmime-4.2.jar:$APPDIR/../../Java/httpmime-4.2.jar:$APPDIR/../../Java/java-objc-bridge-1.0.0.jar:$APPDIR/../../Java/jcommon-1.0.16.jar:$APPDIR/../../Java/jfreechart-1.0.13.jar:$APPDIR/../../Java/jhotdraw-6.0b1.jar:$APPDIR/../../Java/jhotdraw-6.0b1.jar:$APPDIR/../../Java/jmf-2.1.1e.jar:$APPDIR/../../Java/jmf-2.1.1e.jar:$APPDIR/../../Java/jna-4.2.2.jar:$APPDIR/../../Java/jogl-all-2.3.2.jar:$APPDIR/../../Java/jogl-all-2.3.2.jar:$APPDIR/../../Java/json-simple-1.1.1.jar:$APPDIR/../../Java/json-simple-1.1.1.jar:$APPDIR/../../Java/log4j-1.2.16.jar:$APPDIR/../../Java/log4j-1.2.16.jar:$APPDIR/../../Java/macro-compat_2.12-1.1.1.jar:$APPDIR/../../Java/macro-compat_2.12-1.1.1.jar:$APPDIR/../../Java/netlogo-6.0.1.jar:$APPDIR/../../Java/netlogo-6.0.1.jar:$APPDIR/../../Java/netlogo-mac-app.jar:$APPDIR/../../Java/parboiled-core-1.1.7.jar:$APPDIR/../../Java/parboiled-core-1.1.7.jar:$APPDIR/../../Java/parboiled-java-1.1.7.jar:$APPDIR/../../Java/parboiled-java-1.1.7.jar:$APPDIR/../../Java/parboiled_2.12-2.1.3.jar:$APPDIR/../../Java/parboiled_2.12-2.1.3.jar:$APPDIR/../../Java/pegdown-1.6.0.jar:$APPDIR/../../Java/pegdown-1.6.0.jar:$APPDIR/../../Java/picocontainer-2.13.6.jar:$APPDIR/../../Java/picocontainer-2.13.6.jar:$APPDIR/../../Java/rsyntaxtextarea-2.6.0.jar:$APPDIR/../../Java/rsyntaxtextarea-2.6.0.jar:$APPDIR/../../Java/scala-library-2.12.0.jar:$APPDIR/../../Java/scala-library-2.12.1.jar:$APPDIR/../../Java/scala-library-2.12.1.jar:$APPDIR/../../Java/scala-parser-combinators_2.12-1.0.5.jar:$APPDIR/../../Java/scala-parser-combinators_2.12-1.0.5.jar:$APPDIR/../../Java/shapeless_2.12-2.3.2.jar:$APPDIR/../../Java/shapeless_2.12-2.3.2.jar
app.runtime=$APPDIR/../../JRE
app.identifier=org.nlogo.app
[JVMOptions]
-Dnetlogo.extensions.dir=$APPDIR/../../extensions
-Dnetlogo.models.dir=$APPDIR/../../models
-Dnetlogo.docs.dir=$APPDIR/../../docs
-Xdock:name=NetLogo
-Dorg.nlogo.mac.appClassName=org.nlogo.app.App$
-Xmx1024m
-Dfile.encoding=UTF-8
-Dapple.awt.graphics.UseQuartz=true
[JVMUserOptions]
[ArgOptions]
This seemed promising, but literally deleting this file had no affect on my ability to run NetLogo by opening the application/ using the Control API with Java method. As such, I am stumped, so any help would be greatly appreciated.

Running SimpleOpenNI and leJOS in same project

We have a project in which we want to control a Lego Mindstorms robot with the Microsoft Kinect sensor. We decided to use SimpleOpenNI with Processing to read the sensor and leJOS to control the robot for a simple reason: since both is in Java, we can specifiy a kind of RoboHandler and call its methods from the sensor reading class.
In order to achieve that, we downloaded the leJOS plugin for eclipse, created a new leJOS NXT project and put the processing and SimpleOpenNI libraries in the build path. Note that to use SimpleOpenNI, it is required an old processing version without Java.
Now the problem is, that when installing leJOS, it strictly requires a 32-bit Java JDK, so I had to download this and point to it at installation.
At this point, following build paths are in the project:
LeJOS NXT Runtime (which has among others java.awt classes)
core.jar (used to run Processing in eclipse)
SimpleOpenNI.jar
Having all this, and setting up a first Processing sketch like
import processing.core.*;
public class Test extends PApplet{
(....)
}
results in following error code:
Multiple markers at this line
- The type java.awt.event.MouseMotionListener cannot be resolved. It is indirectly referenced from
required .class files
- The type java.applet.Applet cannot be resolved. It is indirectly referenced from required .class files
- The type java.awt.event.MouseListener cannot be resolved. It is indirectly referenced from required .class files
- The hierarchy of the type FirstTry is inconsistent
- The type java.awt.event.FocusListener cannot be resolved. It is indirectly referenced from required .class files
- The type java.awt.event.KeyListener cannot be resolved. It is indirectly referenced from required .class files
When I downloaded the Processing without Java version, I wasn't able to choose from 32bit- or 64bit version. The SimpleOpenNI is installed as 64bit-version.
When adding the 64bit-JDK (eclipse workspace default) as workspace too, the error disappears, but when trying to run a sketch, following error gets printed in the console:
Invalid layout of java.lang.Thread at name
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (javaClasses.cpp:128), pid=9176, tid=8740
# fatal error: Invalid layout of preloaded class
#
# JRE version: 7.0_04-b22
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.0-b21 mixed mode windows-amd64 compressed oops)
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Valentino\Desktop\workspaces\workspace_processing\RoboZeugs\bin\hs_err_pid9176.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
So in my oppinion there is a problem with the JDK versions (32 and 64 bit), but there must be a way to handle this. Has anyone experience on this specific topic, maybe even with Kinect -> Mindstorms? Can anybody tell me what this error exactly means?
You're mixing classes that are designed to run with the JVM on the NXT brick (i.e. everything in classes.jar) with classes that are designed to run with a fully fledged JVM on the PC.
Don't do that. If you want to remote control an NXT, use pccomms.jar and everything else in lib/pc. But never add classes.jar or anything else in lib/nxt to the classpath when you're starting a Java program on your PC.
The error message about java.lang.Thread is probably due to the fact, that java.lang.Thread in classes.jar in by no means compatible with java.lang.Thread that comes with the JVM on your PC.