无法从.java类文件中加载主类

时间:2019-02-07 06:17:37

标签: java python gephi

我正在使用Python通过jupyter笔记本通过名为wot的工具来可视化图形。它利用了基于Java的图形实用程序Gephi。我尝试运行函数以返回坐标输出文件,如下所示:

run_gephi(input_graph_file, output_coord_file, n_steps):
    layout = 'fa'
    import psutil
    memory = int(0.5 * psutil.virtual_memory()[0] * 1e-9)
classpath = os.path.dirname(
    pkg_resources.resource_filename('wot', 'commands/resources/graph_layout/GraphLayout.class')) + ':' + \
            pkg_resources.resource_filename('wot', 'commands/resources/graph_layout/gephi-toolkit-0.9.2-all.jar')
subprocess.check_call(['java', '-Djava.awt.headless=true', '-Xmx{memory}g'.format(memory=memory), '-cp', classpath, \
                       'GraphLayout', input_graph_file, output_coord_file, layout, str(n_steps), str(os.cpu_count())])

然后在我的jupyter笔记本中返回以下错误:

CalledProcessError                        Traceback (most recent call last)
<ipython-input-18-5fc832689b87> in <module>
----> 1 df, adata = compute_force_layout(ds)

<ipython-input-7-6cb84b9e0fa0> in compute_force_layout(ds, n_neighbors, n_comps, neighbors_diff, n_steps)
 24                 writer.write("{u} {v} {w:.6g}\n".format(u=i + 1, v=j + 1, w=W[i, j]))
 25 
---> 26     run_gephi(input_graph_file, output_coord_file, n_steps)
 27     # replace numbers with cids
 28     df = pd.read_table(output_coord_file, header=0, index_col='id')

<ipython-input-16-28772d0d10cc> in run_gephi(input_graph_file, output_coord_file, n_steps)
  7                 pkg_resources.resource_filename('wot', 'commands/resources/graph_layout/gephi-toolkit-0.9.2-all.jar')
  8     subprocess.check_call(['java', '-Djava.awt.headless=true', '-Xmx{memory}g'.format(memory=memory), '-cp', classpath, \
----> 9                            'GraphLayout', input_graph_file, output_coord_file, layout, str(n_steps), str(os.cpu_count())])

~/anaconda3/lib/python3.7/subprocess.py in check_call(*popenargs, **kwargs)
339         if cmd is None:
340             cmd = popenargs[0]
--> 341         raise CalledProcessError(retcode, cmd)
342     return 0
343 

CalledProcessError: Command '['java', '-Djava.awt.headless=true', '-Xmx25g', '-cp', '/home/iik/.local/lib/python3.7/site-packages/wot/commands/resources/graph_layout:/home/iik/.local/lib/python3.7/site-packages/wot/commands/resources/graph_layout/gephi-toolkit-0.9.2-all.jar', 'GraphLayout', '/tmp/gephiznxedn32.net', '/tmp/coordsd64x05ww.txt', 'fa', '10000', '8']' returned non-zero exit status 1.

,并在终端中找到以下消息

 Error: Could not find or load main class GraphLayout

我可以在路径中找到“ GraphLayout.java”和“ gephi-toolkit-0.9.2-all.jar”文件,所以我真的不知道为什么无法加载它。 你有什么建议吗?

  • 添加*

Gephi中不包含GraphLayout类,但由GraphLayout.java定义。

0 个答案:

没有答案