opcode81 / ProbCog

A toolbox for statistical relational learning and reasoning.
GNU General Public License v3.0
101 stars 26 forks source link

grade-ext example - no module named random #17

Closed AnujGandhi123 closed 5 years ago

AnujGandhi123 commented 5 years ago

genDB -b gen.py trainUniversity WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.python.google.common.base.internal.Finalizer (file:/home/anuj/.m2/repository/org/python/jython/2.5.3/jython-2.5.3.jar) to field java.lang.Thread.inheritableThreadLocals WARNING: Please consider reporting this to the maintainers of org.python.google.common.base.internal.Finalizer WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Exception in thread "main" Traceback (most recent call last): File "gen.py", line 5, in from random import choice, randint, shuffle ImportError: No module named random

i get this error when i run genDB...How do i solve it?

opcode81 commented 5 years ago

The warnings are due to an incompatibility between Java 9+ and Jython, see http://bugs.jython.org/issue2705. It should be fixed in Jython 2.7.2, so you can try changing the dependency if it's already been released. I don't have time to try it out right now, but if you do, please try it and issue a pull request if it works.

I am not sure if the import error is a consequence of the warnings, but I suspect it might be so. The module "random" is, after all, included in the Jython standard library and therefore imports should really never fail.

opcode81 commented 5 years ago

Unfortunately, Jython 2.7.2 has not been released yet, so if you need to get this running right now, I think you might have to use Java 8 instead of Java 9.

AnujGandhi123 commented 5 years ago

Do you have a copy of the generated database file in the mean time? I'd like to take a look at that.

opcode81 commented 5 years ago

Turns out the warnings actually weren't the problem. It was a dependency issue introduced during the migration to Maven. The issue has been fixed with the latest commit 83e6e18. Rebuild using maven (mvn package), then rerun make_apps, and you should be good to go.