我想學習如何在命令行中運行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']
您是否安裝了多個python版本? – 2013-05-12 20:26:57
@ThomasFenzl是的,我有很多版本的python通過macports安裝,但(我認爲)只有一個版本的ipython('py27-ipython @ 0.13.2')。一般來說,我使用python 2.7.3(通過'python_select'選擇) – DilithiumMatrix 2013-05-13 00:02:30
你可以檢查ipython是否在你的shell中使用了相同的python背景嗎?你可以例如'import sys;打印sys.path'並檢查兩個 – 2013-05-13 05:53:01