2013-07-15 3 views
1

그래서 networkx 그래프를 생성하고 .graphml로 내 보낸 python 스크립트가 있는데 스크립트가 네트워크에서 cytoscape를 열 수있게하려면 사용자 부분. 이해 :cmd와 Python을 사용하여 Cytoscape에서 네트워크 파일 열기.

cytoscape.bat -N C:\Somepath\with\a\networkx.graphml 

그리고 사용하면 문제가 없습니다. 않는 :

p = subprocess.Popen("cytoscape.bat", cwd="C:/Program Files/Cytoscape_v3.0.0") 
stdout, stderr = p.communicate() 

그러나이 파일 찾을 수 없다는-예외가 발생합니다 :

cd "C:\Program Files\Cytoscape_v3.0.0" 
cytoscape.bat 

을하지만, 나도 os.system 또는 subprocess 제대로 실행 얻을 수없는 것, 내 현재의 구성은 .

다른 stackoverflow 게시물과 .bats를 실행하고 cmd 작업을 수행하는 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 

A는 약간 다른 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 
+0

당신이 전체 예외 데이터를 제공 할 수 있습니까? – jsalonen

+1

이 완료, 나는 낯선 사람의 JVM 오류 어떤 os.system을 추가했습니다 호출하면 생성됩니다 – Darkstarone

+1

Poposcan 명령을 cytoscape.bat 디렉토리에서 실행하고 있습니까? 'cwd' 명령을 실행하기 전에 디렉토리를 변경하지만 [documentation] (http://docs.python.org/2/library/subprocess .html # popen-constructor)는 다음과 같이 말한다 :이 디렉토리는 실행 파일을 검색 할 때 고려되지 않으므로, ** cwd **에 상대적인 프로그램의 경로를 지정할 수 없다 .. –

답변

1

에서

으로 나는 예외를 요청 the documentation :

"cwd가 None이 아닌 경우 t 그 아이의 현재 디렉토리는 실행되기 전에 cwd로 변경됩니다. 이 디렉토리는 실행 파일을 검색 할 때 고려되지 않으므로 cwd에 상대적인 프로그램의 경로를 지정할 수 없습니다. "

당신은 subprocess.Popen에 명령의 전체 경로를 통과해야합니다.

관련 문제