首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用brew (Macosx)安装vtk后:"import vtk“中止python控制台

使用brew (Macosx)安装vtk后:"import vtk“中止python控制台
EN

Stack Overflow用户
提问于 2016-10-14 00:00:50
回答 1查看 1.4K关注 0票数 0

我试图用自制软件安装vtk,但是,现在当我在Python上使用import vtk时,我的python会话中止了……

我在MacOSX上工作,我做了这样的事情:

代码语言:javascript
复制
brew install vtk --with-qt --with-python --with-pyqt

它返回:

代码语言:javascript
复制
....
[ 29%] Built target vtkFiltersCore
    make: *** [all] Error 2

    READ THIS: https://git.io/brew-troubleshooting
    If reporting this issue please do so at (not Homebrew/brew):
      https://github.com/Homebrew/homebrew-science/issues
....

在那之后,我读到我应该使用这句话:

代码语言:javascript
复制
HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install vtk --qt --python --pyqt

很长一段时间后,它会返回:

代码语言:javascript
复制
....
 ==> Caveats
    Even without the --with-qt option, you can display native VTK render windows
    from python. Alternatively, you can integrate the RenderWindowInteractor
    in PyQt, PySide, Tk or Wx at runtime. Read more:
        import vtk.qt4; help(vtk.qt4) or import vtk.wx; help(vtk.wx)

    Python modules have been installed and Homebrew's site-packages is not
    in your Python sys.path, so you will not be able to import the modules
    this formula installed. If you plan to develop with these modules,
    please run:
      mkdir -p /Users/TheUser/Library/Python/2.7/lib/python/site-packages
      echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/TheUser/Library/Python/2.7/lib/python/site-packages/homebrew.pth
    ==> Summary
      /usr/local/Cellar/vtk/7.0.0_3: 3,203 files, 107.7M

所以我运行了mkdir & echo行

当我在Python控制台中尝试import vtk时,它返回:

代码语言:javascript
复制
    Fatal Python error: PyThreadState_Get: no current thread
    Abort trap: 6

我稍后重新尝试重新安装它:

代码语言:javascript
复制
==> Installing vtk from homebrew/science
Error: vtk-7.0.0_3 already installed
To install this version, first `brew unlink vtk`

所以我解除了链接,并重新运行了HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install vtk --qt --python --pyqt

结果是:

代码语言:javascript
复制
==> Patching VTK to use system Python 2
==> Caveats
Even without the --with-qt option, you can display native VTK render windows from python. Alternatively, you can integrate the RenderWindowInteractor in PyQt, PySide, Tk or Wx at runtime. Read more:
    import vtk.qt4; help(vtk.qt4) or import vtk.wx; help(vtk.wx)

VTK was linked against your system copy of Python.
If you later decide to change Python installations, relink VTK with:

  brew postinstall vtk
==> Summary
  /usr/local/Cellar/vtk/7.0.0_5: 3,204 files, 107.7M

当我在python控制台上使用import vtk时:中止!

我怎么才能修复它呢?

EN

回答 1

Stack Overflow用户

发布于 2016-10-14 00:51:45

我目前正在更新到vtk/7.0.0_5 (之前使用过7.0.0_3 ),我用来安装它的代码行是:

代码语言:javascript
复制
brew install vtk --with-qt --with-qt5 --with-python 

我在python (2.7)中使用它时没有遇到任何问题。

好了--所以刚刚完成了对7.0.0_5的升级,我收到了同样的信息,谢谢。但是启动python和启动完全没有问题:

代码语言:javascript
复制
> $ python                                                                     
Python 2.7.12 (default, Oct 11 2016, 05:20:59) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin 
Type "help", "copyright", "credits" or "license" for more information.
>>> import vtk
>>> import vtk.qt4

希望能帮上忙,

斯蒂芬

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40025812

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档