2017-05-20 92 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