enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

from mayavi import mlab not working #721

Open saitoasukakawaii opened 5 years ago

saitoasukakawaii commented 5 years ago

Hi, I am new to Mayavi. I have just installed it and I want to run such code but it failed,can you tell me how to solve the problem?

from scipy.integrate import odeint import numpy as np from mayavi import mlab def lorenz(w, t, a, b, c):

给出位置矢量w,和三个参数a, b, c计算出

# dx/dt, dy/dt, dz/dt的值
x, y, z = w.tolist()
# 直接与lorenz的计算公式对应
return np.array([a * (y - x), x * (b - z) - y, x * y - c * z])

t = np.arange(0, 30, 0.01) # 创建时间点

track1 = odeint(lorenz, (0.0, 1.00, 0.0), t, args=(10.0, 28.0, 3.0)) track2 = odeint(lorenz, (0.0, 1.01, 0.0), t, args=(10.0, 28.0, 3.0))

绘制图形

mlab.plot3d(track1[:, 0], track1[:, 1], track1[:, 2], color=(1, 0, 0), tube_radius=0.1) mlab.plot3d(track2[:, 0], track2[:, 1], track2[:, 2], color=(0, 0, 1), tube_radius=0.1)

The error is as follows:

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 . 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

Thanks a lot!

prabhuramachandran commented 5 years ago

Can you please provide more details on your mayavi installation? How did you install this version of Mayavi, which version have you installed? OS, Python version, all these will help figure out if this is an issue or an installation problem.