HyperSpy API has changed in version 2.0, see the release notes!

Installing HyperSpy#

The easiest way to install HyperSpy is to use the HyperSpy Bundle, which is available on Windows, MacOS and Linux.

Alternatively, HyperSpy can be installed in an existing python distribution, read the conda installation and pip installation sections for instructions.


To enable the context-menu (right-click) shortcut in a chosen folder, use the start_jupyter_cm tool.


If you want to be notified about new releases, please Watch (Releases only) the hyperspy repository on GitHub (requires a GitHub account).


Since version 0.8.4 HyperSpy only supports Python 3. If you need to install HyperSpy in Python 2.7 install HyperSpy 0.8.3.

HyperSpy Bundle#

The HyperSpy bundle is very similar to the Anaconda distribution, and it includes:

For instructions, see the HyperSpy bundle repository.

Portable distribution (Windows only)#

A portable version of the HyperSpy bundle based on the WinPython distribution is also available on Windows.

Installation using conda#

Conda is a package manager for Anaconda-like distributions, such as the Miniforge or the HyperSpy-bundle. Since HyperSpy is packaged in the conda-forge channel, it can easily be installed using conda.

To install HyperSpy run the following from the Anaconda Prompt on Windows or from a Terminal on Linux and Mac.

$ conda install hyperspy -c conda-forge

This will also install the optional GUI packages hyperspy_gui_ipywidgets and hyperspy_gui_traitsui. To install HyperSpy without the GUI packages, use:

$ conda install hyperspy-base -c conda-forge


Depending on how Anaconda has been installed, it is possible that the conda command is not available from the Terminal, read the Anaconda User Guide for details.


Using -c conda-forge is only necessary when the conda-forge channel is not already added to the conda configuration, read the conda-forge documentation for more details.


Depending on the packages installed in Anaconda, conda can be slow and in this case mamba can be used as an alternative of conda since the former is significantly faster. Read the mamba documentation for instructions.

Further information#

When installing packages, conda will verify that all requirements of all packages installed in an environment are met. This can lead to situations where a solution for dependencies resolution cannot be resolved or the solution may include installing old or undesired versions of libraries. The requirements depend on which libraries are already present in the environment as satisfying their respective dependencies may be problematic. In such a situation, possible solutions are:

  • use Miniconda instead of Anaconda, if you are installing a python distribution from scratch: Miniconda only installs very few packages so satisfying all dependencies is simple.

  • install HyperSpy in a new environment. The following example illustrates how to create a new environment named hspy_environment, activate it and install HyperSpy in the new environment.

$ conda create -n hspy_environment
$ conda activate hspy_environment
$ conda install hyperspy -c conda-forge


A consequence of installing hyperspy in a new environment is that you need to activate this environment using conda activate environment_name where environment_name is the name of the environment, however shortcuts can be created using different approaches:

To learn more about the Anaconda eco-system:

Installation using pip#

HyperSpy is listed in the Python Package Index. Therefore, it can be automatically downloaded and installed pip. You may need to install pip for the following commands to run.

To install all of HyperSpy’s functionalities, run:

$ pip install hyperspy[all]

To install only the strictly required dependencies and limited functionalities, use:

$ pip install hyperspy

See the following list of selectors to select the installation of optional dependencies required by specific functionalities:

  • ipython for integration with the ipython terminal and parallel processing using ipyparallel,

  • learning for some machine learning features,

  • gui-jupyter to use the Jupyter widgets GUI elements,

  • gui-traitsui to use the GUI elements based on traitsui,

  • speed install numba and numexpr to speed up some functionalities,

  • tests to install required libraries to run HyperSpy’s unit tests,

  • coverage to coverage statistics when running the tests,

  • doc to install required libraries to build HyperSpy’s documentation,

  • dev to install all the above,

  • all to install all the above except the development requirements (tests, doc and dev).

For example:

$ pip install hyperspy[learning, gui-jupyter]

Finally, be aware that HyperSpy depends on a number of libraries that usually need to be compiled and therefore installing HyperSpy may require development tools installed in the system. If the above does not work for you remember that the easiest way to install HyperSpy is using the HyperSpy bundle.

Update HyperSpy#

Using conda#

To update hyperspy to the latest release using conda:

$ conda update hyperspy -c conda-forge

Using pip#

To update hyperspy to the latest release using pip:

$ pip install hyperspy --upgrade

Install specific version#

Using conda#

To install a specific version of hyperspy (for example 1.6.1) using conda:

$ conda install hyperspy=1.6.1 -c conda-forge

Using pip#

To install a specific version of hyperspy (for example 1.6.1) using pip:

$ pip install hyperspy==1.6.1

Rolling release Linux distributions#

Due to the requirement of up to date versions for dependencies such as numpy, scipy, etc., binary packages of HyperSpy are not provided for most linux distributions and the installation via Anaconda/Miniconda or Pip is recommended.

However, packages of the latest HyperSpy release and the related GUI packages are maintained for the rolling release distributions Arch-Linux (in the Arch User Repository) (AUR) and openSUSE (Community Package) as python-hyperspy and python-hyperspy-gui-traitsui, python-hyperspy-gui-ipywidgets for the GUIs packages.

A more up-to-date package that contains all updates to be included in the next minor version release (likely including new features compared to the stable release) is also available in the AUR as python-hyperspy-git.

Install development version#

Clone the hyperspy repository#

To get the development version from our git repository you need to install git. Then just do:

$ git clone https://github.com/hyperspy/hyperspy.git


When running hyperspy from a development version, it can happen that the dependency requirement changes in which you will need to keep this this requirement up to date (check dependency requirement in setup.py) or run again the installation in development mode using pip as explained below.

Installation in a Anaconda/Miniconda distribution#

Optionally, create an environment to separate your hyperspy installation from other anaconda environments (read more about environments here):

$ conda create -n hspy_dev python # create an empty environment with latest python
$ conda activate hspy_dev # activate environment

Install the runtime and development dependencies requirements using conda:

$ conda install hyperspy-base -c conda-forge --only-deps # install hyperspy dependencies
$ conda install hyperspy-dev -c conda-forge # install developer dependencies

The package hyperspy-dev will install the development dependencies required for testing and building the documentation.

From the root folder of your hyperspy repository (folder containing the setup.py file) run pip in development mode:

$ pip install -e . --no-deps # install the currently checked-out branch of hyperspy

Installation in other (non-system) Python distribution#

From the root folder of your hyperspy repository (folder containing the setup.py file) run pip in development mode:

$ pip install -e .[dev]

All required dependencies are automatically installed by pip. If you don’t want to install all dependencies and only install some of the optional dependencies, use the corresponding selector as explained in the Installation using pip section

Installation in a system Python distribution#

When using a system Python distribution, it is recommended to install the dependencies using your system package manager.

From the root folder of your hyperspy repository (folder containing the setup.py file) run pip in development mode.

$ pip install -e --user .[dev]

Creating Debian/Ubuntu binaries#

You can create binaries for Debian/Ubuntu from the source by running the release_debian script

$ ./release_debian


For this to work, the following packages must be installed in your system python-stdeb, debhelper, dpkg-dev and python-argparser are required.