JSmile + python + MAC setup problem

The engine.
Post Reply
3d93
Posts: 2
Joined: Wed Oct 26, 2016 9:11 am

JSmile + python + MAC setup problem

Post by 3d93 »

Dear Genie & Smile Community,

I am a newbie in programming with Smile and it would be great if you could help me a little bit to start.

For my academia research project I am trying to setup the following configuration: JSmile + Python on Mac .
By following the instructions I successfully installed prerequisites (jpype).

Currently, I am having difficulties to import JSmile library in a python program .

Here is my testing py code that constantly returns the “ImportError: No module named jsmile” error message:
… from jsmile import SMILEException
ImportError: No module named jsmile …
Here is a small test program that I am using:

Code: Select all

#this part seems to work

import jpype 
jvmPath = jpype.getDefaultJVMPath() 
jvmArg = "-Xint"
jpype.startJVM(jvmPath,jvmArg)

# it seems that the following part is not working... here is the physical location of the 
#library at computer... I tried also to put only  “jsmile_macosx_x64” as a relative path
# to be concatenated to the absolute path without success.

from jpype import *  
import os.path  
jarpath = os.path.join('/Users/my_user_name/jsmile_macosx_x64/')

# tried to use some function from the JSmile library to test the code

from jsmile import SMILEException
net = jpype.JClass("smile.Network")

shutdownJVM()
I am probably doing something wrong but cannot figure out what.
Any help would be great. Thank you.

With kind regards,
Tom
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: JSmile + python + MAC setup problem

Post by shooltz[BayesFusion] »

The code below worked for me on Windows last time we were asked about using jSMILE with JPype. Let me know if you encounter any problems.

Code: Select all

import jpype  
jvmCP = "-Djava.class.path=FULL PATH (NOT ONLY DIR) OF YOUR smile.jar"
jvmLP = "-Djava.library.path=DIRECTORY CONTAINING libjsmile.jnilib"
jpype.startJVM(jpype.getDefaultJVMPath(),jvmCP,jvmLP)
jpype.java.lang.System.out.println("JVM started")
smile = jpype.JPackage("smile")
net = smile.Network()
print net.getName()
3d93
Posts: 2
Joined: Wed Oct 26, 2016 9:11 am

Re: JSmile + python + MAC setup problem

Post by 3d93 »

Dear shooltz,

thank you for your help and prompt response.
I think you helped me a lot.

Now my program responds with the following code:

Code: Select all

JVM started
Unnamed
[Finished in 0.3s]
I assume that is the right response and now I can continue to build my BN :-).
Thank you ...
Tom
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: JSmile + python + MAC setup problem

Post by shooltz[BayesFusion] »

I assume that is the right response
Yes, the default string returned by the Network.getName() is "Unnamed".
Post Reply