深圳爱智慧科技有限公司 深度学习 人工智能 智能投顾 机器学习 中国版kensho 深圳爱智慧科技有限公司
安装mayavi有两种方法:
一种是安装集成了多个python包的软件,如 Enthought Canopy, Pythonxy, 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.
---------------------------------------------------------------------------
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