Installing via the “Bundle”#
If you are brand new to Python, the easiest way to install HyperSpy is using the “standalone” bundle package. This simple to install program provides a customized Python installation that has the HyperSpy libraries pre-installed. It is compatible with Windows, MacOS, or Linux, and is the recommended way to install if you are not familiar with managing Python environments. Instructions can be found in the HyperSpy Bundle’s documentation (here), and an example of the installation process (for Windows) is provided below.
Download#
First, navigate to the repository home page (https://github.com/hyperspy/hyperspy-bundle), and click on the download button slightly down the page:
On the releases page, click on the appropriate installer for your system. There are a few options depending on the type of processor your computer has. For Windows or Linux, you should pick the “Intel” or “AMD” option depending on your type of CPU, since those versions are optimized for each type of processor. For Mac, you will need to choose either “Intel” (for older computers) or “M1” for the newer “Apple Silicon” machines:
Installing#
After the download finishes, run the .exe
file, accepting the default options.
Doing so will install HyperSpy into the folder you choose under a subfolder named
hyperspy-bundle
. Depending on your system, the installation may take quite some
time (especially on the “Setting up the package cache…” and
“Setting up the base environment…” steps), but you should get a progress
window that looks like:
Once the installation eventually finishes, click the Next button, and then Finish to exit the installer.
And that’s it! You should now have a few new applications in your Start Menu, including the “Miniforge Prompt” and “HyperSpyUI” (we won’t be using the UI in this session, but you may play around with it if you’re interested). You can either continue following the next section to test your installation is working correctly, or continue to the Obtaining the tutorial data section on the main page.
Testing the installation#
If you would like to test that your installation is working properly, you can run a small test example by opening the “Qt Console”. This is an interactive Python interpreter that allows you to type in Python statements directly. You can start the Qt Console by using the “Hyperspy-bundle Prompt”, which you will find in the Start Menu:
Once the Hyperspy-bundle prompt opens, type jupyter qtconsole
and press “Enter”
to launch the QT Console:
The Qt Console is an interactive Python interpreter that allows you to enter
Python statements directly and immediately see their output. Once the console
has opened and you see a prompt that says In [1]:
, copy the following code
snippet at the location of the blinking cursor:
%matplotlib qt
import hyperspy.api as hs
s = hs.datasets.artificial_data.get_core_loss_eels_signal(add_powerlaw=True)
s.remove_background()
Very briefly, this code is loading the interactive plotting libraries, loading
HyperSpy, creating an example EELS signal from some artificial data, and then
telling the interpreter you want to interactively remove the Power Law
background. Press Shift-Enter
within the console to run the lines of code
you pasted in (it may take a few moments to run if this is the first time
you’ve used HyperSpy on your machine):
Eventually, you should see a spectrum window and a small tool window for removing the background open (they may be stacked on top of each other; drag them out of the way, if so). If you click and drag on part of the spectrum display, HyperSpy will fit a Power Law to the signal within that region, and also show you a preview of the background-subtracted signal:
Clicking “OK” in the Background removal tool window will perform the background subtraction, and replace the window with one showing the resulting signal:
Assuming all of this worked, congratulations! You have a working HyperSpy installation and you have run your first bit of open-source HyperSpy-based materials science data analysis! Click the button below to return to the main tutorial homepage: