Ask Your Question
3

'launched jmol viewer for Graphics3d Object' fails

asked 2017-10-25 16:27:25 -0500

c05772 gravatar image

updated 2017-12-01 07:43:03 -0500

tmonteil gravatar image

Testing Sagemath for windows 8.0 with jmol, I get the message at the console but nothing happens. However the jmol viewer (launched with jmol.bat) found in C:\Program Files\SageMath 8.0\runtime\opt\sagemath-8.0\local\share\jmol is working correctly.

> sage: G=sphere((0,0,0),1) 
> sage: show(G,figsize=(5,5),title="Sample Figure",aspect_ratio=1); 
> Launched jmol viewer for Graphics3d Object  
> sage:

It looks like a path problem but I don't see how to modify it.

edit retag flag offensive close merge delete

Comments

You are probably right. A workaround would be to use the Tachyon viewer.

kcrisman gravatar imagekcrisman ( 2017-10-27 11:39:50 -0500 )edit
1

Indeed, you need a Java runtime IIRC, and a way for Sage to find it which is currently missing. The tachyon viewer works though and should probably be set as the default (in fact I thought it was...)

Iguananaut gravatar imageIguananaut ( 2017-10-27 13:15:33 -0500 )edit

Sage is now using the Javascript version of Jmol, so there is no need for a Java runtime environment. Have you tried the threejs viewer?

sage: show(G,figsize=(5,5),title="Sample Figure",aspect_ratio=1, viewer='threejs')

Threejs should become at some point Sage's default 3D viewer. Contrary to Tachyon it is interactive and contrary to Jmol, it is fast and can render axes labels.

eric_g gravatar imageeric_g ( 2017-10-28 03:02:47 -0500 )edit
1

Thanks for reporting, it is tracked at https://github.com/sagemath/sage-wind...

tmonteil gravatar imagetmonteil ( 2017-12-01 07:42:50 -0500 )edit
1

Actually yeah, when I specify viewer='jmol' is uses JSMol and seems to work fine, at least in the notebook. But when I run it from the console I get a RuntimeError: jmol cannot run, no suitable java version found, so it's still trying to use the Java version. I'm not sure what the intended behavior is supposed to be in this case--should it instead open a JSMol viewer in a browser?

Iguananaut gravatar imageIguananaut ( 2017-12-11 04:28:52 -0500 )edit

1 answer

Sort by » oldest newest most voted
3

answered 2017-12-21 01:00:57 -0500

tani gravatar image

I've got the identical situation occurring. What I've noticed is that if I open the sage shell and run jmol I get:

(sage-sh) tani@DESKTOP-HUU9IR5:~$ jmol
/opt/sagemath-8.1/local/share/jmol
Error: Unable to access jarfile /opt/sagemath-8.1/local/share/jmol/Jmol.jar

However, if I go in to /opt/sagemath-8.1/local/share/jmol/ and run jmol it works:

(sage-sh) tani@DESKTOP-HUU9IR5:~$ cd /opt/sagemath-8.1/local/share/jmol/
(sage-sh) tani@DESKTOP-HUU9IR5:jmol$ ls
appletweb         COPYRIGHT.txt  Jmol.jar  JmolData.jar   LEAME.txt
build.README.txt  jmol           jmol.mac  JmolLib.jar    LICENSE.txt
CHANGES.txt       jmol.bat       jmol.sh   JSpecView.jar  README.txt
(sage-sh) tani@DESKTOP-HUU9IR5:jmol$ jmol
/opt/sagemath-8.1/local/share/jmol
splash_image=jar:file:/C:/Program%20Files/SageMath%208.1/runtime/opt/sagemath-8.1/local/share/jmol/Jmol.jar!/org/openscience/jmol/app/images/Jmol_splash.jpg
history file is C:\Users\XXX\.jmol\history
user properties file is C:\Users\XXX\.jmol\properties
(C) 2015 Jmol Development
Jmol Version: 14.6.1_2016.07.11  2016-07-11 18:22
java.vendor: Java: Oracle Corporation
java.version: Java 1.8.0_151
os.name: Windows 10
Access: ALL
memory: 8.9/16.3
processors available: 8
useCommandThread: false
User macros dir: C:\Users\XXX\.jmol\macros
       exists: false
  isDirectory: false

I believe I understand part of what the underlying issue is. The java I have is a windows java that expects windows pathnames. I can make it work by editing the jmol shell script to run this:

java -Xmx512M -jar "c:\\program files\\sagemath 8.1\\runtime\\opt\\sagemath-8.1\\local\\share\\jmol\\Jmol.jar"

This will launch jmol from within sage, when you run things like

G=sphere((0,0,0),1)
show(G,figsize=(5,5),title="Sample Figure",aspect_ratio=1);

So it seems like sage is expecting to run a java that works with these unix-like paths, but the java that is installed only accepts windows-like paths. In any case, launching jmol doesn't actually make the image display correctly. This is because the arguments that are passed contain another unix-like path, ie:

/dot_sage/temp/DESKTOP-HUU9IR5/21144/dir_JxIjMK/scene.spt

Once I modified that to have a windows-like path, I then opened that file and found that the file itself contained more unix-like paths. Once I modified that remaining path to a windows-like path, jmol did in fact render the image that I wanted.

So, this is obviously an awful solution, but what I've done is replaced the jmol bash script with a python script that takes all the parameters, modifies them to use windows paths, and runs java. It's dirty but it works.

#!/opt/sagemath-8.1/local/bin/python

import sys
import os
import re

scriptname = sys.argv[1]
original_scriptname = scriptname

scriptname = re.sub(r'/dot_sage/',r"c:\\\\users\\\\YOUR_USERNAME_HERE\\\\.sagemath-8.1\\\\",scriptname)
scriptname = re.sub(r'/',r"\\\\",scriptname)
zip = "%s.zip" % scriptname

with open(original_scriptname,"w") as f:
   f.write("set defaultdirectory \"%s\"\n" % zip);
   f.write("script SCRIPT\n");

os.system("java -Xmx512m -jar \"c:\\program files\\sagemath 8.1\\runtime\\opt\\sagemath-8.1\\local\\share\\jmol\\Jmol.jar\" \"%s\"" % scriptname)
edit flag offensive delete link more

Comments

Wow, this is impressive. I wonder if we can update the Jmol to be a "Unix-friendly" one?

kcrisman gravatar imagekcrisman ( 2018-01-04 15:43:52 -0500 )edit

Indeed, this is an issue in a few other places as well--Sage is generating a cygwin (Unix-like) path and passing it to the system java which doesn't understand it. I need to patch Sage in a few places to ensure that on Cygwin it produces a Windows path. In the meantime this is a great workaround.

Iguananaut gravatar imageIguananaut ( 2018-01-05 09:23:03 -0500 )edit

If you can let us know the exact patch that would be great - we could probably incorporate it with some switch for OS.

kcrisman gravatar imagekcrisman ( 2018-01-15 20:08:14 -0500 )edit

I haven't made the patch yet; obviously it would be cygwin-specific.

Iguananaut gravatar imageIguananaut ( 2018-01-22 09:09:49 -0500 )edit

Tani's script is a "great unusable" solution.I wonder if another work around would not be to have sage export directly the necessary file(s) in the working directory so that a vizualisation with a pure windows jmol installation could work (or even the sagemath installation which could be accessed directly through a .bat file).

For now, I found on internet and I tried: SaveJmolFigure = tmp_filename(ext=".jmol") G.export_jmol('/cygdrive/e/User/SaveJmolFigure.jmol') but it fails.

c05772 gravatar imagec05772 ( 2018-03-02 18:10:38 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2017-10-24 17:03:23 -0500

Seen: 478 times

Last updated: Dec 21 '17