深圳爱智慧科技有限公司 深度学习 人工智能 智能投顾 机器学习 中国版kensho 深圳爱智慧科技有限公司html
安装mayavi有两种方法:python
一种是安装集成了多个python包的软件,如 Enthought Canopy, Pythonxy, orAnaconda.可是貌似几个集成环境中都没有看到mayavi的影子。git
第二种就是从源代码开始安装:安装mayavi以前先要安装这几个依赖包github
You must have the following libraries installed before installing the Mayavi project:api
那么先开始安装vtk吧。两种方法:一:app
首先安装vtk:less
安装VTK,从网站http://www.vtk.org/VTK/resources/software.html 下载最新版本,此文安装的是:vtkpython-6.1.0-Windows-64bit.exepython2.7
3)配置VTK环境变量:机器学习
A:把VTK中的bin文件加入系统变量中:如:PATH:C:\Program Files\VTK 6.1.0\binide
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
================================================================================================================================
下面是一个例子
运行这个例子提醒没有安装“ffmpeg.win32.exe”
从https://github.com/imageio/imageio-binaries/blob/master/ffmpeg/ffmpeg.win32.exe下载了个“ffmpeg.win32.exe”文件。
而后在用户和系统环境变量里面新建一个名字叫“IMAGEIO_FFMPEG_EXE”,值是你存放这个exe文件的地址的变量。