从IPython运行VisIt

时间:2013-05-12 20:24:50

标签: python ipython

我正在尝试学习如何从命令行运行VisIt,并且我已经能够使用visit -cli创建绘图并提供Python命令,即OpenDatabase("somefile.vtk")

除了ipython解释器之外,还有相同的事情吗?

我试过

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

这给了我错误'module' object has no attribute 'OpenDatabase'

另一方面,如果我跑

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

打开VisIt GUI,忽略visit.Launch()之后的所有内容。

  • VisIt 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']

2 个答案:

答案 0 :(得分:0)

我不确定你们是否认识到这一点,但我不确定除非你从头开始访问,否则它是可能的。如果你下载他们的二进制文件,它会安装自己的python,并重置你的PYTHONPATH,并添加某些库。看看他们的启动脚本(bin / visit),应该可以构建VisIt以使用系统python,此时你可能会鼓励它使用系统ipython。但这可以在VisIt配置时完成,而不是在运行时完成。

那就是说,如果你确实想办法解决问题,请发一个答案,因为我也想知道!

答案 1 :(得分:0)

在OSX上运行更难,因为你需要用自己的python手动修复硬编码的python路径,比如anaconda 2。

VisIt是使用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版本的Visit,也许可以针对OSX进行修改。