6

The following import

from mayavi import mlab

generates the value error.

I installed Mayavi using setuptools (as described here). The gui works fine (some bugs here and there but still I can use the modules etc.) I am guessing some thing didn't went well with the install. Any suggestions how I can fix my installation(if that is what the problem is) ?

Edit 1:

I uninstalled mayavi and reinstalled it (using pip), but the valueError is still present.

Edit 2:

The system I have the installation on is a virtual Ubuntu 15.04 (using VMware 6.0.6). I have pasted the pip install mayavi output here.

Edit 3: After reinstalling a previous version of Mayavi : 4.3.1, I still get the same error. I am using Python : 2.7.9.

imranal
  • 656
  • 12
  • 35
  • What OS? What Python distribution? Where are you running your code from? (Python script in terminal, IPython terminal, Canopy GUI,....) – Jonathan March Nov 14 '15 at 17:29
  • @JonathanMarch I do not have access to the machine I was running on at the moment, I will add the specific version in the post by tomorrow. (Ubuntu 15 on VMware fusion.) – imranal Nov 15 '15 at 13:05

3 Answers3

2

Don't know, whether my answer is relevant now, but this helped me: I have PyQt4 on my machine, but I've installed wxPython for Mayavi, so they were conflicting. I've removed wxPython and now it works just perfect.

Charlie
  • 826
  • 1
  • 11
  • 27
  • Your answer is correct. There is a post however on SO : http://stackoverflow.com/questions/16350884/how-to-get-mayavi2-to-default-to-use-qt-rather-than-wx where you can do this without uninstalling : `export ETS_TOOLKIT=qt4` . I found out about it on the Mayavi github : https://github.com/enthought/mayavi/issues/265 – imranal Nov 25 '15 at 17:22
2

There is a post on SO :

How to get MayaVi2 to default to/use Qt rather than wx?

where it shows how you can set qt4, without having to uninstall wxPython (as the other answer suggests) :

export ETS_TOOLKIT=qt4

I found out about it among the issues section on the Mayavi github : Issue 265

Community
  • 1
  • 1
imranal
  • 656
  • 12
  • 35
0

Dude, maybe you made the same silly mistake as I did, LOL.

Same Error

I was trying to use WXAgg as backend for matplotlib and traitsui but I got a RuntimeError: Importing from wx backend after selecting qt4 backend. The import part is as follows:

import matplotlib
# We want matplotlib to use a wxPython backend
matplotlib.use('WXAgg')
import wx

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from traits.api import Instance
from traitsui.wx.editor import Editor
from traitsui.wx.basic_editor_factory import BasicEditorFactory

Then I tried to manually change the backend with following codes:

from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'wx'

Guess what, I got the same ValueError: cannot set toolkit to wx because it has already been set to qt4 as you do.

Check Before You Go

After hours of searching and debugging, I almost gave up until suddenly I recall that I have set this variable system wide once. How stupid I am not to follow this hint and check ETS_TOOLKIT!

Anybody who come across this error again, pls check you system settings with echo $ETS_TOOLKIT on Linux or echo %ETS_TOOLKIT% on Windows. If it says qt4, then it's your fault causing this error.

Joshz
  • 594
  • 5
  • 12