2

I tried installing mayavi on Colab using pip:

!pip install mayavi

This threw the following error:

Running setup.py bdist_wheel for mayavi ... error

The rest of the error output is available at the Colab document.


Solution: Work in Progress

Following the response from @Bob-Smith, I found that his solution needed a slight change for installing the dependencies:

!apt-get install vtk6
!apt-get install libvtk6-dev python-vtk6


Problems Faced and Workaround Found (PFWF)

PFWF-001 !apt-get install python-vtk throws the following error:

Package 'python-vtk' has no installation candidate

I found a command-reference for this:

!apt-get install libvtk5-dev python-vtk

However, this command also did not work. The package name had changed from libvtk5-dev to libvtk6-dev and the python binding for VTK has changed from python-vtk to python-vtk6. Clearly this kind of change will continue to happen in future and you may need to check the package name and the python binding for VTK before running the following statement:

!apt-get install libvtk6-dev python-vtk6

Note: If you are here looking to solve VTK installation problems for python and this does not solve that you may want to look here: installing-vtk-for-python


Installing mayavi still throws error:
Although the two steps above install the dependencies, the last line: !pip install mayavi spits out the following error:

Could not connect to any X display.

The latest progress on Mayavi installation can be found here.

https://colab.research.google.com/drive/1K_VIP9izNLKalD_IgBSiTowyNkU7aWcW

0x90
  • 39,472
  • 36
  • 165
  • 245
CypherX
  • 7,019
  • 3
  • 25
  • 37
  • What did you end up doing? – 0x90 Oct 30 '18 at 16:06
  • I tried those commands but after a point the progress stops: ```Setting up qt5-gtk-platformtheme:amd64 (5.9.5+dfsg-0ubuntu1) ... Setting up ubuntu-mono (16.10+18.04.20181005-0ubuntu1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... Processing triggers for systemd (237-3ubuntu10.3) ... Processing triggers for dbus (1.12.2-1ubuntu1) ...``` – CypherX Nov 05 '18 at 23:28
  • 1
    I have added a fresh copy of my latest installation effort in this [Colab](https://colab.research.google.com/drive/1K_VIP9izNLKalD_IgBSiTowyNkU7aWcW) document. importing **`mlab`** throws error now. – CypherX Nov 05 '18 at 23:40

2 Answers2

0

You'll first need to install deps. Run

!apt-get install vtk6
!apt-get install python-vtk
!pip install mayavi

If you've attempted to import myavi before installing the deps, you may need to restart you runtime before executing the !pip install myavi command using the Runtime -> Restart runtime menu.

Bob Smith
  • 36,107
  • 11
  • 98
  • 91
  • Thank you @BobSmith. "!apt-get install python-vtk" did not execute without error. Source was not available. – CypherX Jul 25 '18 at 20:55
  • `!pip install mayavi` throws error after the dependencies are installed. Details are updated in the main description. – CypherX Jul 25 '18 at 22:23
0

I was trying to do the same thing and I was getting error like this. So I tried install vtk package with conda. You need conda to install vtk of course so:

!wget -c https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
!chmod +x Miniconda3-4.5.4-Linux-x86_64.sh
!bash ./Miniconda3-4.5.4-Linux-x86_64.sh -b -f -p /usr/local
!conda install -q -y --prefix /usr/local python=3.6 ujson
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')
import ujson
print(ujson.dumps({1:2}))
!conda --version

Then set up vtk package with conda as:

!apt-get install vtk6
!conda install -c anaconda vtk

I was trying to install mayavi for mne package so:

!conda activate mne
!conda install gxx_linux-64=7.3
!pip install https://api.github.com/repos/enthought/mayavi/zipball/226189a6ad3dc3c01d031ef21d0d0cde554ac851

Be careful because you need to mne package to activate so before installing mayavi (I was trying to install mne as I said before):

!pip install mne