Python包安装——mayavi安装

深圳爱智慧科技有限公司 深度学习 人工智能 智能投顾 机器学习 中国版kensho 深圳爱智慧科技有限公司


安装mayavi有两种方法:

一种是安装集成了多个python包的软件,如 Enthought CanopyPythonxy, orAnaconda.但是貌似几个集成环境中都没有看到mayavi的影子。

第二种就是从源代码开始安装:安装mayavi之前先要安装这几个依赖包

You must have the following libraries installed before installing the Mayavi project:

那么先开始安装vtk吧。两种方法:

一:

首先安装vtk:

安装VTK,从网站http://www.vtk.org/VTK/resources/software.html 下载最新版本,此文安装的是:vtkpython-6.1.0-Windows-64bit.exe

3)配置VTK环境变量:

A:把VTK中的bin文件加入系统变量中:如:PATH:C:\Program Files\VTK 6.1.0\bin

B:设置python路径,在系统变量中创建PYTHONPATH :如:PYTHONPATH :C:\Program Files\VTK 6.1.0\bin;C:\Program Files\VTK 6.1.0\bin\Lib\site-packages

4)测试,打开python IDEL界面,输入:import vtk

>>> import vtk
>>> 

没报错,就说明安装成功了。

我是直接把site-packages里面的vtk拷贝到了python27下面的site-packages中


安装VTK的第二种方法,从源代码开始安装(需要先编译VTK,由于是win10系统没成功



好吧,装了了vtk之后再到mayavi-4.4.3文件夹下运行python setup.py install 还是不成功。


于是又老老实实看了Enthought Canopy发现vtk,tvtk还有traits啥的还是有的,尽管就是没有mayavi,先装个Canopy,然后把site-packages里面的vtk拷贝到了python27下面的site-packages中


我擦,不科学,怎么会这样




特么竟然有了,有了!!!!!!直接考到python27下面的site-packages中

import mayavi.mlab as mlab

遇到ValueError: cannot set toolkit to wx because it has already been set to qt4的问题

从这个网址看到的解决方案

Hi, 

Building traitsui GUIs from the ipython notebook should work the same as from a regular ipython console. The difference between configure_traits and edit_traits is that the first one creates a GUI event loop before building the traitsUI window in it. That's what makes it responsive or not. Alternatively you can manually start the GUI event loop by specifying --gui=?? when you create ipython, for example:
ipython notebook --gui=wx
Then you should use edit_traits() and the UI element will be responsive. 

Finally, ETSConfig allows you to set the backend at your script runtime instead of when you start python/ipython. This is what I do the most so that I don't need to set the value of the ETSConfig environment variable, or set the gui switch when starting python/ipython.

To conclude, the following code is what I do the most and works from within the ipython notebook started with ipython notebook (version 0.13):
from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'qt4'

from traits.api import HasTraits, Enum
from traitsui.api import View

class A(HasTraits):
    x = Enum(["foo","bar"])

a = A()
a.configure_traits()

HTH, 
Jonathan



Thanks, Jonathan.


I would like to follow your advice, but am getting some errors. When I try this at the top of a new notebook, I get:

from traits.api import *
from traits.etsconfig.api import ETSConfig
from traitsui.api import *
ETSConfig.toolkit = 'qt4'

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-8a5daaa83ef1> in <module>()
----> 1 ETSConfig.toolkit = 'qt4'

/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/traits/etsconfig/etsconfig.py in _set_toolkit(self, toolkit)
    208         if self._toolkit and self._toolkit != toolkit:
    209             raise ValueError, "cannot set toolkit to %s because it has "\
--> 210                             "already been set to %s" % (toolkit, self._toolkit)
    211 
    212         self._toolkit = toolkit

ValueError: cannot set toolkit to qt4 because it has already been set to wx

Any idea what might be causing this? I suspect the other error below on starting ipython-qtconsole may be related, but am equally clueless about this. I think both these worked until recently. 

Ah, Google to the rescue
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值