title: Mayavi doesn't run from within Spyder: complains about "ValueError: API 'QString' ..."
body: <p>I am unable to run/use Mayavi library from within Spyder IDE. I have described the problem below. Any help will be very useful. (Thank you very much in advance.)</p>
  <p><strong>Steps to reproduce the problem:</strong></p>
  <ol>
  <li>Just importing the Mayavi library in a script (for example using &quot;import mayavi.mlab as mlab&quot;) and executing the script will reproduce this problem.</li>
  <li>I am including a test code (note that this code is an example code from the Mayavi website) here to reproduce the problem:</li>
  </ol>
  <h1>code</h1>
  <pre><code>from numpy import sin, cos, mgrid
  import mayavi.mlab as mmlab
  
  def f(x,y):
    return sin(x + y) + sin(2*x - y) + cos(3*x + 4*y)
          
  x,y = mgrid[-7.:7.05:0.01, -5.:5.05:0.05]
  z = f(x,y)
  s = mmlab.contour_surf(x,y,z)
  mmlab.show()
  </code></pre>
  <p><strong>Expected output and the Error:</strong></p>
  <p>Expected output: A Mayavi figure window with the figure.
  What I see instead: The following Value error (I am including the full sequence of message in order to be explicit)in the console window:</p>
  <p><em>-------------------------- Beginning of error message ------------------</em></p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\PROGRAMSANDEXPERIMENTS\PYTHON\MayaviScripts\Learning\testMayavi.py&quot;, line 2, in &lt;module&gt;
      import mayavi.mlab as mmlab
    File &quot;C:\Python27\lib\site-packages\mayavi\mlab.py&quot;, line 27, in &lt;module&gt;
      from mayavi.tools.camera import view, roll, yaw, pitch, move
    File &quot;C:\Python27\lib\site-packages\mayavi\tools\camera.py&quot;, line 25, in &lt;module&gt;
      from engine_manager import get_engine
    File &quot;C:\Python27\lib\site-packages\mayavi\tools\engine_manager.py&quot;, line 12, in &lt;module&gt;
      from mayavi.preferences.api import preference_manager
    File &quot;C:\Python27\lib\site-packages\mayavi\preferences\api.py&quot;, line 4, in &lt;module&gt;
      from preference_manager import preference_manager
    File &quot;C:\Python27\lib\site-packages\mayavi\preferences\preference_manager.py&quot;, line 29, in &lt;module&gt;
      from traitsui.api import View, Group, Item
    File &quot;C:\Python27\lib\site-packages\traitsui\api.py&quot;, line 35, in &lt;module&gt;
      from .editors.api import (ArrayEditor, BooleanEditor, ButtonEditor,
    File &quot;C:\Python27\lib\site-packages\traitsui\editors\__init__.py&quot;, line 22, in &lt;module&gt;
      from .api import (toolkit, ArrayEditor, BooleanEditor, ButtonEditor,
    File &quot;C:\Python27\lib\site-packages\traitsui\editors\api.py&quot;, line 10, in &lt;module&gt;
      from .code_editor import CodeEditor
    File &quot;C:\Python27\lib\site-packages\traitsui\editors\code_editor.py&quot;, line 36, in &lt;module&gt;
      class ToolkitEditorFactory ( EditorFactory ):
    File &quot;C:\Python27\lib\site-packages\traitsui\editors\code_editor.py&quot;, line 48, in ToolkitEditorFactory
      mark_color = Color( 0xECE9D8 )
    File &quot;C:\Python27\lib\site-packages\traits\traits.py&quot;, line 487, in __call__
      return self.maker_function( *args, **metadata )
    File &quot;C:\Python27\lib\site-packages\traits\traits.py&quot;, line 1183, in Color
      return ColorTrait( *args, **metadata )
    File &quot;C:\Python27\lib\site-packages\traitsui\toolkit_traits.py&quot;, line 7, in ColorTrait
      return toolkit().color_trait( *args, **traits )
    File &quot;C:\Python27\lib\site-packages\traitsui\toolkit.py&quot;, line 109, in toolkit
      _toolkit = _import_toolkit(ETSConfig.toolkit)
    File &quot;C:\Python27\lib\site-packages\traitsui\toolkit.py&quot;, line 51, in _import_toolkit
      return __import__( name, globals=globals(), level=1 ).toolkit
    File &quot;C:\Python27\lib\site-packages\traitsui\qt4\__init__.py&quot;, line 18, in &lt;module&gt;
      import pyface.qt
    File &quot;C:\Python27\lib\site-packages\pyface\qt\__init__.py&quot;, line 35, in &lt;module&gt;
      prepare_pyqt4()
    File &quot;C:\Python27\lib\site-packages\pyface\qt\__init__.py&quot;, line 17, in prepare_pyqt4
      sip.setapi('QString', 2)
    ValueError: API 'QString' has already been set to version 1
  </code></pre>
  <p><em>---------------------------- End of error message --------------------</em></p>
  <p><strong>My environment(s) are the following:</strong></p>
  <p>This issue has been observed at-least in the following two environments:</p>
  <h2>Environment 1:</h2>
  <p>Description: Spyder and all other components were installed using the Pythonxy distribution (Py(x,y)-2.7.2.3.exe) on a Windows 7, 32 bit machine).
  Spyder Version:  2.1.9
  Python Version:  2.7.2 (32 bit)
  Qt Version:      4.7.4, PyQt4 (API v1) 4.8.6 on Windows
  Mayavi Version:  4.1.0</p>
  <h2>Environment 2:</h2>
  <p>Description: On a separate machine running 64 bit Windows 7, I have installed 64-bit version of the Enthought EPD distribution. So it is running 2.7.3 (x64) version of Python distribution. Since the EPD package doesn't include Spyder, I manually installed Spyder after installing PyQt GPLv4.9.4.<br />
  Spyder Version:  2.1.11
  Python Version:  2.7.3 (64 bit)
  Qt Version:      4.8.2, PyQt4 (API v2) 4.9.4 on Windows
  Mayavi Version:  4.2.0</p>
  <p><strong>Additional information:</strong></p>
  <p>I am sure that the code is fine, as the script produces the expected output when executed &quot;outside&quot; spyder environment. For example, using IPython shell.</p>
  <p>Thank you.</p>