Skip to content

Installation & Setup

Requirements

EasyDiffraction is a cross-platform Python library compatible with Python 3.11 through 3.13.
Make sure Python is installed on your system before proceeding with the installation.

Environment Setup optional

We recommend using a virtual environment to isolate dependencies and avoid conflicts with system-wide packages. If any issues arise, you can simply delete and recreate the environment.

Creating and Activating a Virtual Environment:

  • Create a new virtual environment:
    python3 -m venv venv
    
  • Activate the environment:

    . venv/bin/activate
    
    . venv/bin/activate
    
    . venv/Scripts/activate      # Windows with Unix-like shells
    .\venv\Scripts\activate.bat  # Windows with CMD
    .\venv\Scripts\activate.ps1  # Windows with PowerShell
    
  • The terminal should now show (venv), indicating that the virtual environment is active.

Deactivating and Removing the Virtual Environment:

  • Exit the environment:
    deactivate
    
  • If this environment is no longer needed, delete it:

    rm -rf venv
    
    rm -rf venv
    
    rmdir /s /q venv
    

Installation Guide

Installing from PyPI recommended

EasyDiffraction is available on PyPI (Python Package Index) and can be installed using pip. We strongly recommend installing it within a virtual environment, as described in the Environment Setup section.

We recommend installing the latest release of EasyDiffraction with the visualization extras, which include optional dependencies used for simplified visualization of charts and tables. This can be especially useful for running the Jupyter Notebook examples. To do so, use the following command:

pip install 'easydiffraction[visualization]'

If only the core functionality is needed, the library can be installed simply with:

pip install easydiffraction

To install a specific version of EasyDiffraction, e.g., 1.0.3:

pip install 'easydiffraction==1.0.3'

To upgrade to the latest version:

pip install --upgrade --force-reinstall easydiffraction

To check the installed version:

pip show easydiffraction

Installing from GitHub

Installing unreleased versions is generally not recommended but may be useful for testing.

To install EasyDiffraction from, e.g., the develop branch of GitHub:

pip install git+https://github.com/easyscience/diffraction-lib@develop

To include extra dependencies (e.g., visualization):

pip install 'easydiffraction[visualization] @ git+https://github.com/easyscience/diffraction-lib@develop'

How to Run Tutorials

EasyDiffraction includes a collection of Jupyter Notebook examples that demonstrate key functionality. These tutorials serve as step-by-step guides to help users understand the diffraction data analysis workflow.

They are available as static HTML pages in the Tutorials section. You can also run them interactively in two ways:

  • Run Locally – Download the notebook via the Download button and run it on your computer.
  • Run Online – Use the Open in Google Colab button to run the tutorial directly in your browser (no setup required).

Note

You can also download all Jupyter notebooks at once as a zip archive from the EasyDiffraction Releases.

Run Tutorials Locally

To run tutorials locally, install Jupyter Notebook or JupyterLab. Here are the steps to follow in the case of Jupyter Notebook:

  • Install Jupyter Notebook and IPython kernel:
    pip install notebook ipykernel
    
  • Add the virtual environment as a Jupyter kernel
    python -m ipykernel install --user --name=venv --display-name "EasyDiffraction Python kernel"
    
  • Download the EasyDiffraction tutorials from GitHub Releases:
    python -m easydiffraction fetch-tutorials
    
  • Launch the Jupyter Notebook server in the examples/ directory:
    jupyter notebook tutorials/
    
  • In your web browser, go to:
    http://localhost:8888/
    
  • Open one of the *.ipynb files and select the EasyDiffraction Python kernel to get started.

Run Tutorials via Google Colab

Google Colab lets you run Jupyter Notebooks in the cloud without any local installation.

To use Google Colab:

  • Ensure you have a Google account.
  • Go to the Tutorials section.
  • Click the Open in Google Colab button on any tutorial.

This is the fastest way to start experimenting with EasyDiffraction, without setting up Python on your system.

Installing with Pixi alternative

Pixi is a modern package and environment manager for Python and Conda-compatible packages. It simplifies dependency management, environment isolation, and reproducibility.

The following simple steps provide an alternative setup method for EasyDiffraction using Pixi, replacing the traditional virtual environment approach.

  • Install Pixi by following the instructions on the official Pixi Installation Guide.
  • Create a dedicated directory for the EasyDiffraction and navigate into it:
    mkdir easydiffraction
    cd easydiffraction
    
  • Download the pixi configuration file for EasyDiffraction:

    curl -LO https://raw.githubusercontent.com/easyscience/diffraction-lib/master/pixi/prod/pixi.toml
    
    wget https://raw.githubusercontent.com/easyscience/diffraction-lib/master/pixi/prod/pixi.toml
    
  • Create the environment defined in pixi.toml and install all necessary dependencies:

    pixi install
    

  • Fetch the EasyDiffraction tutorials to the tutorials/ directory:
    pixi run easydiffraction fetch-tutorials
    
  • Start JupyterLab in the tutorials/ directory to access the notebooks:
    pixi run jupyter lab tutorials/
    
  • Your web browser should open automatically. Click on one of the *.ipynb files and select the Python (Pixi) kernel to get started.