13

I'm having trouble running mayavi in python 3.3

When running my program with python3 (or python3.3) i get

from mayavi import mlab as ml
ImportError: No module named 'mayavi'

To get numpy and matplotlib to work, i used:

sudo apt-get install python3-"missing module"

But the usual way to install mayavi is just

sudo apt-get install mayavi2

And python3 doesn't find it....

Does anyone know a way to get mayavi to work with Python3? Is it not supported yet?

I have tried both

import mayavi.mlab as ml
from mayavi import mlab as ml

Both give me the same error

Any clarification would be greatly appreciated :)

Hme
  • 243
  • 1
  • 2
  • 6

5 Answers5

14

Mayavi can work with python 3 now. You will need VTK 7.0 or higher compiled for python 3 support. Then you can just install mayavi with pip. pip install mayavi

Installing vtk may prove somewhat difficult. You need to make sure to change the PYTHONPATH variable, and build vtk with tcl, tk, and python 3 support.

Riet
  • 1,240
  • 1
  • 15
  • 28
5

Today, Mayavi is not supported in python3.

See also this github issue:

https://github.com/enthought/mayavi/issues/84

MaxNoe
  • 14,470
  • 3
  • 41
  • 46
cosmoscalibur
  • 1,131
  • 1
  • 8
  • 17
0

I was able to get Mayavi2 to work with Python 3.6.4.

To set up Mayavi on ubuntu, do the following -

  • Install Anaconda/Miniconda distribution of python depending on your needs(I used Miniconda 4.3.30). For more info look here
  • Run the following in terminal -

        apt-get install -y libglib2.0-0 libxext6 libsm6 libxrender1 gtk3.0
        conda install -y -c conda-forge qt vtk pyvtk pyside envisage mesalib mayavi
        conda install -y -c ajsrk traitsui
    

    Ideally , you wouldn't need the last line since traitsui will be installed as part of the dependencies in the previous step. However, I found an issue with this version of traitsui. So as a temporary fix, I have uploaded my version of traitsui into anaconda cloud; this can be used until the fix finds its way into the next release and is available in the conda-forge channel

To verify the installation start a terminal session and type 'mayavi2'

Savvy
  • 547
  • 5
  • 12
  • 1
    Python is DOWNGRADED to 3.5... So, still not working on 3.6. – Gabs Jan 17 '18 at 12:33
  • @Gabs - Are you saying you couldn't get it to work even after trying the above steps? – Savvy Jan 17 '18 at 15:05
  • It works, but Python is downgraded to version 3.5. Also, I've lost all the previous packages that I installed. – Gabs Jan 18 '18 at 12:12
  • That shouldn't happen, normally when you're trying to install a package with irresolvable dependencies, the installation fails, otherwise some existing packages maybe upgraded or downgraded to work. But it never uninstalls any existing packages. Also, I dont know if python will be downgraded.. i think you may already have a pre-existing 3.5.x installation of python. If this is the case, you must first install python 3.6.x version from a suitable anaconda installer. By the way, what is your OS? – Savvy Jan 18 '18 at 13:59
  • My OS is Elementary OS Loki (Ubuntu 16.04). What is yours OS? – Gabs Mar 02 '18 at 03:23
0

The best solution that I`ve found, is this. Even though, Mayavi will only work on Pyathon 3.5...

Gabs
  • 292
  • 5
  • 23
0

My solution is launching Spider from Anaconda 3 and then running the file mayavi2-script.py that can be found in the directory Anaconda/Scripts. It launches the 3D data visualizer as a pop-up window in Windows10.