Как установить mayavi python

Installation¶

This section details the various ways of installing Mayavi.

If you already have Mayavi up and running, you can skip this section.

By itself Mayavi is not a difficult package to install but its dependencies are unfortunately rather heavy. Fortunately, many of these dependencies are now available as wheels on PyPI. The two critical dependencies are,

The latest VTK wheels are available on all the major platforms (Windows, MacOS, and Linux), but only for 64 bit machines. Python 3.x is fully supported on all these operating systems and Python 2.7.x on MacOS and Linux. If you are out of luck, and your platform is not supported then you will need to install VTK yourself using your particular distribution as discussed in the General Build and Installation instructions

On Python 3.x you will need to install PyQt5 and wheels are available for this. On 2.7.x you have more options, and can use PySide, PyQt4, and wxPython. These can be installed from pip or from your package manager.

Currently, Mayavi itself should work with the new wxPython 4.x. However, traitsui, pyface, and other ETS packages do not yet support it so the UI will not work correctly. Older versions should work. PyQt/PySide should work largely out of the box. PySide2 is still young so YMMV.

Installing with pip ¶

pip is the PyPA recommended tool for installing Python packages from PyPI. The latest version of Mayavi available on PyPI can be found here.

Required python packages can be automatically fetched and installed with pip.

Latest stable release¶

As of the latest release, i.e. 4.6.0 and above, if you are using Python 3.x and are on a 64 bit machine, installation via pip is the easiest and is as follows:

$ pip install mayavi $ pip install PyQt5

If you are unable to do this, read the documentation above and find a way to install VTK and a suitable UI toolkit and then repeat the above.

If you are interested in the jupyter notebook support as well, do the following (after ensuring that you have jupyter installed of course):

$ jupyter nbextension install --py mayavi --user $ jupyter nbextension enable --py mayavi --user

You will also need to have ipywidgets and ipyevents installed. These can be installed via pip or your favorite package manager.

Bleeding edge¶

If you want to install the latest version of Mayavi from github, you can simply do the following:

$ git clone https://github.com/enthought/mayavi.git $ cd mayavi $ pip install -r requirements.txt $ pip install PyQt5 # replace this with any supported toolkit $ python setup.py install # or develop

Add the jupyter nbextensions using the instructions in the section above and you should be good to go.

Mayavi depends on several packages that are part of ETS. Sometimes it is possible that the in-development mayavi version may depend on some feature of an unreleased component. The ETS packages that Mayavi depends on are apptools, traits_ , traitsui, pyface, and envisage_ . In case one of these are required these can also be installed via git. They are all relatively easy to install packages.

Читайте также:  Java exec bin sh

Installing ready-made distributions¶

Under Windows the best way to install Mayavi is to install a full Python distribution, such as Enthought Canopy, Pythonxy, or Anaconda. Note that for Pythonxy, you need to check in ‘ETS’ in the installer, when selecting components. If you want to reduce the disk space used by Pythonxy, you can uncheck other components.

The full Python distribution Enthought Canopy (that includes Mayavi) or Anaconda are also available for MacOSX.

Mayavi is packaged in Debian and Ubuntu and can be installed via apt .

The full Python distribution Enthought Canopy (that includes Mayavi) is also available for RHEL3 and 4.

EDM is Enthought’s freely available python environment manager. It allows new python users to create light-weight and custom python environments. A major advantage of EDM is its robust state-of-the-art management of package dependencies, with support for resolving conflicts and ensuring consistent package version sets. It can be downloaded from edmInstaller.

EDM provides Python 2.7.x as well as Python 3.x runtimes. Python 2.7 is the default version. After installing EDM, mayavi can be easily installed from the terminal by using edm :

This will install mayavi along with ‘pyqt’. After this, you can start a shell with the default python version by running:

This should set Mayavi for the default python 2.7.

For python 3.6.x, you can install it by running:

$ edm environments create –version 3.6 py3

Where ‘py3’ is the name of the environment. You may change this name to something else if you wish. Once you create the environment, you can activate it as follows:

You can now install mayavi as follows:

Note that ‘pyqt’ needs to be installed explicitly for python 3.6 as well as for python 2.7.

Conda is an open source package management environment management system for installing multiple versions of software packages and their dependencies. Conda is included in Anaconda and Miniconda.

Miniconda is a small “bootstrap” version that includes conda, python, and the packages they depend on. Depending on your operating system, you can download the MinicondaInstaller

After installing conda you need to run the following from command line:

$ conda create -n pyconda python=3.5 pyqt=4 $ source activate pyconda $ conda install -c menpo mayavi

You should be all set with this. As of Mayavi 4.6.0 you can also use pyqt=5 .

Installing with Conda-forge ¶

Conda-forge is a community-led conda channel of installable packages. For more information on conda-forge, you can vist their their website.

Follow these steps to install using conda-forge:

First, clone the environment or build one from scratch:

$ conda create --name pyforge --clone root or $ conda create --name pyforge python=2.7

Then add the conda-forge channel:

$ conda config --add channels conda-forge

Activate the ‘pyforge’ environment:

You will need to install these dependencies for Mayavi:

$ conda install vtk $ conda install pyqt=4

Finally, Mayavi can be installed as:

Testing your installation¶

The easiest way to test if your installation is OK is to run the mayavi2 application like so:

To get more help on the command try this:

mayavi2 is the mayavi application. On some platforms like win32 you will need to double click on the mayavi2.exe program found in your PythonXY\Scripts folder. Make sure this directory is in your path.

Читайте также:  Черный цвет шрифта css

Mayavi can be used in a variety of other ways but the mayavi2 application is the easiest to start with.

If you have the source tarball of mayavi or have checked out the sources from the github repository, you can run the examples in mayavi*/examples . There are plenty of example scripts illustrating various features. Tests are available in the mayavi*/tests sub-directory.

Test suite¶

The basic test suites for tvtk and mayavi can be run using nose:

nosetests -v tvtk/tests nosetests -v mayavi 

The integration tests can be run as:

cd integrationtests/mayavi python run.py 

Troubleshooting¶

If you are having trouble with the installation you may want to check the Getting help page for more details on how you can search for information or email the mailing list.

Источник

Installation

Currently there are two binaries available. One for Win32 and the other for Linux. The Linux and Win32 binaries were made using Gordon McMillan’s Installer. The Windows installer was made using InnoSetup. Installing the binaries is pretty straight forward. The download is pretty big since it comes bundled with everything necessary to run MayaVi. Please note that when you install the binary, you cannot use MayaVi as a Python module from an existing installation of Python. If you want that, you must install MayaVi from the other installation methods.

Both the binary installations ship with a doc/ directory containing a quick installation guide, README, etc. and a user guide in doc/guide/book1.html. Also included is an examples/ directory that contains a sample VTK data file of a heart CT scan and a visualization based on that data.

Binary installation under Windows

Just download the binary, run it to start the installation, answer the questions on where you want to install it etc. That’s it! If you have problems, please let us know.

Binary installation under Linux

  • glibc2.3.2. This should be standard on most recent Linux installations.
  • Mesa/OpenGL: You will need to have libGL.so.1, libGLU.so.1 and libGLcore.so.1 installed.
  • X11: You will need to have the X libraries installed. The binaries were built with XFree86 4.3. I guess XFree86 4.x should work okay.

Using RPMs, debs or Enthon

RPM

Installing the RPM requires that you have installed Python, Tkinter and the VTK RPMs for VTK and VTK-Python. Once you have these working you can simply install the appropriate (depending on your Python version) MayaVi RPM. If you have installed VTK from the sources and not via RPMS there should be no problem with installing the MayaVi RPM.

Debian package

To install the Debian package simply install the current Debian MayaVi package (using apt-get install mayavi). This will rope in all necessary dependencies. Then simply install the downloaded Debian package. Debian (woody) ships with VTK 3.2. More recent VTK 4.x binaries (not debs) that work under testing (for the i386) are available here. These binaries are built under testing.

Enthought Python for Windows

Enthought distributes an enhanced Python installer that ships with a huge number of very useful Python packages. If you install this, you get a fully functional Python installation with MayaVi installed. Since all MayaVi’s requirements are installed as part of Enthon, if you need to upgrade the version of MayaVi that ships with Enthon, you can simply install MayaVi from sources by following the instructions in the installation of MayaVi section.

Читайте также:  Config yml spigot java

Installation from Sources

MayaVi uses distutils for the installation process. Distutils is part of the Python standard library from versions 2.0 onwards. So, you should normally have this available. MayaVi requires that VTK be installed and usable from Python. For more details please read the MayaVi requirements.

If you would like to install MayaVi from the sources under Debian GNU/Linux you may simply run

Installation of MayaVi

If the requirements are all met, installing MayaVi is simple. Download the tarball, untar/unzip it, change directory to the new directory and do the following:

Thats all there is to it. Under Linux you might want to run this command as root. For more help on the various options for the install command try this:

% python setup.py install --help

Please note that if you simply want to run MayaVi without installing it as a module you can always run it straight from the untarred directory like so:

Requirements

  • MayaVi requires:
    • Python version >= 2.0 and a working Tkinter.
    • A working distutils.
    • The VTK library with the Python bindings, the VTK-Python Tk widget, and the VTK contrib library compiled. Under VTK 4.x you also need to compile the Hybrid classes (there is no ‘contrib’ directory in VTK 4.x) to get all the MayaVi modules to work.

    Usually the hardest part of a MayaVi install when using the sources is getting the VTK Python bindings installed properly. The next section tries to address this.

    Installation of VTK

    Instructions on how to build VTK suitably under Windows for MayaVi are available here. You should also read the README.html that is included with the VTK sources. When building VTK from the sources make sure that you build the Python bindings. It is a good idea to build the Tcl bindings also since that ensures that the VTK-Python Tk widgets are also compiled.

    Pre-built VTK packages are available for Linux and Win32 and these are mentioned below. If installing VTK from sources is a hassle you should consider trying these instead.

    Linux binaries Links to nightly RPMS are available from the VTK download page. A tarball containing all the necessary libraries/modules in order to use VTK from Python is available here. This build uses the latest CVS tree and has been built on the Debian GNU/Linux woody distribution. More details on the installation etc. are available in the README.txt included at the site. Binaries for Windows Windows binaries are also available at the VTK download page. Some old windows binaries for VTK-Python should be available from here. This package has all the necessary items for MayaVi compiled in. Instructions on how to install it are available at the site. You might also be interested in checking out Enthought’s Enhanced Python distribution. MayaVi should be easy to install from source if you are using this.

    The Linux and Win32 binaries pages should be updated reasonably often so do check them out.

    Testing your VTK installation

    Included along with the MayaVi source is a file called test_vtk.py in the doc directory. Run this to test your VTK installation like so:

    Источник

Оцените статью