Installing HyperSpy

The easiest way to install HyperSpy in Microsoft Windows is installing the HyperSpy Bundle.

For quick instructions on how to install HyperSpy in Linux, MacOs or Windows using the Anaconda Python distribution see Quick instructions to install HyperSpy using Anaconda (Linux, MacOs, Windows).

Those experienced with Python may like to Install using Python installers or Install from source.

Warning

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 for Microsoft Windows

New in version 0.6.

The easiest way to install HyperSpy in Windows is installing the HyperSpy Bundle. This is a customised WinPython distribution that includes HyperSpy, all its dependencies and many other scientific Python packages. HyperSpy Bundle does not interact with any other Python installation in your system, so it can be safely installed alongside other Python distributions. Moreover it is portable, so it can be installed to a USB key. When installing it with administrator rights for all users it adds context (right-click) menu entries to start the Jupyter Notebook and Juypter QtConsole inside the folder being clicked. See start_jupyter_cm for details.

Quick instructions to install HyperSpy using Anaconda (Linux, MacOs, Windows)

Anaconda is recommended for the best performance (it is compiled using Intel MKL libraries) and the easiest installation. The academic license is free.

  1. Download and install Anaconda. If you are not familiar with Anaconda please refer to their User Guide for details.

  2. Then install HyperSpy executing the following conda commands in the Anaconda Prompt, Linux/Mac Terminal or Microsoft Windows Command Prompt. (This depends on your OS and how you have installed Anaconda, see the Anaconda User Guide) for details.

    $ conda config --add channels conda-forge
    $ conda install hyperspy
    

Note

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

$ conda install traitsui
$ pip install --upgrade hyperspy==0.8.3-1

To enable context-menu (right-click) startup in a chosen folder, install start_jupyter_cm. (Currently only available for Gnome and Windows, not MacOS.)

For more options and details read the rest of the documentation.

Install using Python installers

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.

Install using pip:

$ pip install hyperspy

Warning

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

$ pip install --upgrade hyperspy==0.8.3-1

pip installs automatically the strictly required libraries. However, for full functionality you may need to install some other dependencies, see Installing the required libraries. Also, be aware that HyperSpy depends on a number of libraries that usually need to be compiled and therefore installing HyperSpy may require development tools. If the above does not work for you remember that the easiest way to install HyperSpy is using Anaconda.

Creating Conda environment for HyperSpy

Anaconda Python distribution can be easily set up using environment files. The two required steps are:

  1. Download HyperSpy environment file.
  2. Create and activate HyperSpy environment according to instructions here. For Unix, the following should work:
$ conda config --add channels conda-forge
$ conda env create -f anaconda_hyperspy_environment.yml
$ source activate hyperspy

Install from a binary

We provide binary distributions for Windows (see the Downloads section of the website). To install easily in other platforms see Install using Python installers

Install from source

Released version

To install from source grab a tar.gz release and in Linux/Mac (requires to Installing the required libraries manually):

$ tar -xzf hyperspy.tar.gz
$ cd hyperspy
$ python setup.py install

You can also use a Python installer, e.g.

$ pip install hyperspy.tar.gz

Development version

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

To install HyperSpy you could proceed like in Released version. However, if you are installing from the development version most likely you will prefer to install HyperSpy using pip development mode:

$ cd hyperspy
$ pip install -e ./

All required dependencies are automatically installed by pip. However, for extra functonality you may need to install some extra dependencies, see Installing the required libraries. Note the pip installer requires root to install, so for Ubuntu:

$ cd hyperspy
$ sudo pip install -e ./

With development mode setup.py generates or updates git post-checkout hook, which will cleanup the cythonized c files, cythonize it again and run `build_ext --inplace` after the next checkout.

Creating Debian/Ubuntu binaries

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

$ ./release_debian

Warning

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

Installing the required libraries

When installing HyperSpy using Python installers or from source the Python programming language and the following libraries must be installed in the system: numpy, scipy, matplotlib (>= 1.2), ipython, natsort, tqdm, ipyparallel, python-dateutil, traits and traitsui. For full functionality it is recommended to also install h5py, scikit-image, scikit-learn and lxml. If HyperSpy is going to be installed from source, cython is also required.In addition, since version 0.7.2 the lowess filter requires statsmodels. In Windows HyperSpy uses the Ipython’s QtConsole and therefore Qt and PyQt or PySide are also required.

In Debian/Ubuntu you can install the libraries as follows:

$ sudo apt-get install python-numpy python-matplotlib ipython
ipython-notebook python-traits python-traitsui python-h5py
python-scikit-learn python-scikit-image python-nose
python-statsmodels python3-tqdm

Known issues

Windows

  • If HyperSpy fails to start in Windows try installing the Microsoft Visual C++ 2008 redistributable packages ( 64 bit or 32 bit) before reporting a bug.

  • In some Windows machines an error is printed at the end of the installation and the entries in the context menu and the Start Menu are not installed properly. In most cases the problem can be solved by restarting the computer and reinstalling HyperSpy.

  • Concerning older installations with the “Hyperspy here” context menus: Due to a Python bug sometimes uninstalling HyperSpy does not uninstall the “Hyperspy here” entries in the context menu. Please run the following code in a Windows Terminal (command line prompt) with administrator rights to remove the entries manually:

    > uninstall_hyperspy_here
    
  • If HyperSpy raises a MemoryError exception:

    • Install the 64bit version if you’re using the 32bit one and you are running HyperSpy in a 64bit system.
    • Increase the available RAM by closing other applications or physically adding more RAM to your computer.