所以我有一个 python 脚本,它生成一个 networkx 图形并将其导出为 .graphml,我希望脚本也能够在加载网络的情况下打开 cytoscape,而无需用户部分进行任何工作。我明白:
cytoscape.bat -N C:\Somepath\with\a\networkx.graphml
当我使用它时它工作正常。就像这样:
cd "C:\Program Files\Cytoscape_v3.0.0"
cytoscape.bat
但是,我似乎无法获得os.system
或subprocess
无法正常运行,我当前的配置是:
p = subprocess.Popen("cytoscape.bat", cwd="C:/Program Files/Cytoscape_v3.0.0")
stdout, stderr = p.communicate()
但是会引发文件未找到异常。
我一直在阅读有关运行 .bats 和执行 cmd 操作的其他 stackoverflow 帖子和 python 文档,并且可以让基础知识发挥作用。但是,这似乎有点复杂,我不确定我哪里出错了!
根据要求,我例外:
找不到文件和不正确的路径异常:
Traceback (most recent call last):
File "CytoScapeExporter.py", line 219, in <module>
p = subprocess.Popen("cytoscape.bat", cwd="\"C:/Program Files/Cytoscape_v3.0
.0\"")
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 267] The directory name is invalid
Traceback (most recent call last):
File "CytoScapeExporter.py", line 219, in <module>
p = subprocess.Popen("cytoscape.bat", cwd="C:/Program Files/Cytoscape_v3.0.0
")
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
一个稍微不同的 JVM 错误,它是由以下代码产生的:
os.system("\"C:/Program Files/Cytoscape_v3.0.0/cytoscape.bat\"")
Error: missing `server' JVM at `C:\Program Files (x86)\Java\jre7\bin\server\jvm.
dll'.
Please install or use the JRE or JDK that contains these missing components.
C:\Program Files\Cytoscape_v3.0.0