2017-05-20 59 views
0

我在windows上使用python 3.5,并根据以前的经验,使用python 2.7的mayavi教程后,版本不应该是一个巨大的障碍,但事实证明这是一个巨大的障碍。这里有一个简单的测试代码:难度在python中使用mayavi 3

import numpy as np 
from mayavi import mlab 
t = np.linspace(0, 4 * np.pi, 50) 
x = np.sin(2 * t) 
y = np.cos(t) 
z = np.cos(2 * t) 
s = 1 + np.sin(t) 
mlab.points3d(x, y, z, s) 

这就是我得到了(我的文件夹名称被删除)

Traceback (most recent call last): 
    File "C:\...\PlotsPartOne.py", line 602, in <module> 
    Main() 
    File "C:\...\PlotsPartOne.py", line 590, in Main 
    mayaviTest() 
    File "C:\...\PlotsPartOne.py", line 582, in mayaviTest 
    mlab.points3d(x, y, z, s) 
    File "C:\Users\...\Anaconda3\lib\site-packages\mayavi-4.5.0-py3.5-win-amd64.egg\mayavi\tools\helper_functions.py", line 37, in the_function 
    return pipeline(*args, **kwargs) 
    File "C:\Users\...\Anaconda3\lib\site-packages\mayavi-4.5.0-py3.5-win-amd64.egg\mayavi\tools\helper_functions.py", line 77, in __call__ 
    scene = tools.gcf().scene 
    File "C:\Users\...\Anaconda3\lib\site-packages\mayavi-4.5.0-py3.5-win-amd64.egg\mayavi\tools\figure.py", line 113, in gcf 
    engine = get_engine() 
    File "C:\Users\...\Anaconda3\lib\site-packages\mayavi-4.5.0-py3.5-win-amd64.egg\mayavi\tools\engine_manager.py", line 101, in get_engine 
    return self.new_engine() 
    File "C:\Users\...\Anaconda3\lib\site-packages\mayavi-4.5.0-py3.5-win-amd64.egg\mayavi\tools\engine_manager.py", line 146, in new_engine 
    check_backend() 
    File "C:\Users\...\Anaconda3\lib\site-packages\mayavi-4.5.0-py3.5-win-amd64.egg\mayavi\tools\engine_manager.py", line 49, in check_backend 
    ''') 
ImportError: Could not import backend for traits 
_______________________________________________________________________________ 
Make sure that you have either the TraitsBackendWx or the TraitsBackendQt 
projects installed. If you installed Mayavi with easy_install, try 
easy_install <pkg_name>. easy_install Mayavi[app] will also work. 

If you performed a source checkout, be sure to run 'python setup.py install' 
in Traits, TraitsGUI, and the Traits backend of your choice. 

Also make sure that either wxPython or PyQT is installed. 
wxPython: http://www.wxpython.org/ 
PyQT: http://www.riverbankcomputing.co.uk/software/pyqt/intro 

而且我敢肯定,我已经安装了wxPython中,性状和PyQt的(第5版) ,但不知道是否安装了TraitsBackendWx或TraitsBackendQt,我搜索了,并没有找到任何可用于python 3的包...但sence mayavi有一个python 3版本,必须有一种方法来运行python上的mayavi代码3(我想......)。那么,有什么办法解决这个问题?

回答

0

我得到它在Ubuntu的工作: sudo易于得到安装python3-pyside

相关

其他模块有: VTK 8.1.0 Mayavi的4.5.0 蟒蛇3.5.2