2013-05-12 52 views
2
運行參觀

我想學習如何在命令行中運行VisIt,我已經能夠使使用visit -cli地塊,並給予Python命令,即OpenDatabase("somefile.vtk")從IPython的

有反正除ipython口譯員之外做同樣的事情?

我已經試過

import visit 
visit.OpenDatabase("somefile.vtk") 

這給我的錯誤'module' object has no attribute 'OpenDatabase'

如果,另一方面,我

import visit 
visit.Launch() 
visit.OpenDatabase("somefile.vtk") 
... 

訪問GUI被打開,一切visit.Launch()後運行被忽略。

  • 參觀2.6
  • IPython的0.13
  • 的Mac OSX 10.8.3

編輯:

import sys 
print sys.path 

IPython中

['', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MeshPy-2013.1-py2.7-macosx-10.8-x86_64.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytest-2.3.4-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytools-2012.1-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py-1.4.13-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/decorator-3.4.0-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.dev3763-py2.7-macosx-10.8-x86_64.egg', 
'/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg', 
'/Library/Python/2.7/site-packages/matplotlib-1.2.0-py2.7-macosx-10.8-intel.egg', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/site-packages', 
'/Users/lzkelley', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/readline', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', 
'/Users/lzkelley/Library/Python/2.7/lib/python/site-packages', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyObjC', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info', 
'/Library/Python/2.7/site-packages', 
'/Library/Python/2.7/site-packages/PIL', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/extensions'] 

蟒蛇

['', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MeshPy-2013.1-py2.7-macosx-10.8-x86_64.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytest-2.3.4-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pytools-2012.1-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/py-1.4.13-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/decorator-3.4.0-py2.7.egg', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astropy-0.3.dev3763-py2.7-macosx-10.8-x86_64.egg', 
'/Library/Python/2.7/site-packages/pip-1.2.1-py2.7.egg', 
'/Library/Python/2.7/site-packages/matplotlib-1.2.0-py2.7-macosx-10.8-intel.egg', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/site-packages', 
'/Users/lzkelley', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/readline', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', 
'/Users/lzkelley/Library/Python/2.7/lib/python/site-packages', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyObjC', 
'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info', 
'/Library/Python/2.7/site-packages', 
'/Library/Python/2.7/site-packages/PIL'] 

訪問-cli

['', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/bin', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/site-packages', 
'/Users/lzkelley', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python26.zip', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/plat-darwin', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/plat-mac', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/plat-mac/lib-scriptpackages', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/lib-tk', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/lib-old', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/lib-dynload', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/site-packages', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/python/lib/python2.6/site-packages/PIL', 
'/Users/lzkelley/Applications/visit/VisIt.app/Contents/Resources/2.6.1/darwin-x86_64/lib/site-packages'] 
+1

您是否安裝了多個python版本? – 2013-05-12 20:26:57

+0

@ThomasFenzl是的,我有很多版本的python通過macports安裝,但(我認爲)只有一個版本的ipython('py27-ipython @ 0.13.2')。一般來說,我使用python 2.7.3(通過'python_select'選擇) – DilithiumMatrix 2013-05-13 00:02:30

+0

你可以檢查ipython是否在你的shell中使用了相同的python背景嗎?你可以例如'import sys;打印sys.path'並檢查兩個 – 2013-05-13 05:53:01

回答

0

我不知道,如果你們想通了這一點,但我不知道這是不可能的,除非你從零開始建立訪問。如果你下載他們的二進制文件,它會安裝它自己的Python,並重置你的PYTHONPATH,並添加某些庫。看看他們的啓動腳本(bin/visit),應該可以構建VisIt來使用系統python,在這一點上,你可能會鼓勵它使用系統ipython。但是這將在VisIt配置時完成,而不是在運行時完成。

這就是說,如果你確實想出了一種方法來解決問題,請發表一個答案,因爲我也想知道!

0

聞聽此事OSX上運行是困難,因爲你必須手動用自己的蟒蛇修復2.

訪問是建立與Python 2硬編碼蟒蛇的路徑,像蟒蛇的,因此進口將不會使用Python 3工作。

下面是一個OSX的腳本:

OSX import configuration

在Windows

否則根據VisitManual你可以簡單地添加您的光臨安裝路徑和重要訪問,並與像腳本啓動它:

import sys 
import os 

sys.path.append("C:/Program Files/LLNL/VisIt 2.12.2/lib/site-packages") 

winSavePath = os.getenv('USERPROFILE') 

import visit 
visit.Launch() 

import visit_utils as vu 

作爲示例,所有後續調用都是visit.OpenDatabase()

有一個Linux版本訪問,也許可以修改爲OSX。