2

我正在尝试学习如何从命令行运行VisIt,并且我已经能够使用visit -cli和提供 Python 命令(即 ieOpenDatabase("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()将被忽略。

  • 访问 2.6
  • IPython 0.13
  • Mac OSX 10.8.3

编辑:

import sys
print sys.path

蟒蛇

['',
 '/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']

Python

['',
 '/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']
4

2 回答 2

0

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

也就是说,如果您确实找到了破解方法,请发布答案,因为我也想知道!

于 2013-06-23T17:38:05.397 回答
0

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

VisIt 是使用 Python 2 构建的,因此导入不适用于 python 3。

这是一个 OSX 脚本:

OSX 导入配置

否则,根据 VisitManual 在 Windows 中,您可以简单地附加您的访问安装路径并导入访问并使用如下脚本启动它:

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 进行修改。

于 2017-07-25T20:08:57.443 回答