Installing PlasmaPy

Note

If you would like to contribute to PlasmaPy, please refer to the instructions on installing PlasmaPy for development.

Requirements

PlasmaPy requires Python version 3.6 or newer, and is not compatible with Python 2.7. PlasmaPy requires the following packages for installation:

PlasmaPy also uses the following optional dependencies:

PlasmaPy can be installed with all of the optional dependencies via pip install plasmapy[optional].

Creating a conda environment

We highly recommend installing PlasmaPy from a Python environment created using conda. Conda allows us to create and switch between Python environments that are isolated from each other and the system installation (in contrast to this xkcd), while also simplifying the distribution of binary and compiled dependencies.

After installing conda, create a PlasmaPy environment by running:

conda create -n plasmapy python=3.7 numpy scipy astropy matplotlib cython h5py lmfit mpmath colorama -c conda-forge

To activate this environment, run:

conda activate plasmapy

Once the environment is activated, then you may proceed with installation.

Installation

Note

We recommend that new users create a conda environment.

Installation with pip

To install the most recent release of PlasmaPy on PyPI with pip into an existing Python environment alongside all optional dependencies, run

pip install plasmapy[optional]

To install a minimal set of dependencies (which does not guarantee that everything will run and may result in ImportError`s, skip `[all] and run simply

pip install plasmapy

Installation with conda

We’re not on conda just yet, but we’re working on it!

Conda installs all dependencies by default.

Building and installing from source code

Prerequisites

Building PlasmaPy from source requires a C compiler such as gcc so that code generated by Cython may be compiled.

Obtaining source code

Stable release

The source code for the most recent stable release of PlasmaPy can be downloaded from PyPI.

Development version on GitHub

If you have git installed on your computer, you may clone PlasmaPy’s GitHub repository and access source code from the most recent development version by running:

git clone https://github.com/PlasmaPy/PlasmaPy.git

The above command uses HTTPS, which is the default protocol and more straightforward to set up. If you have set up an SSH key, then an equivalent and more secure command is:

git clone git@github.com:PlasmaPy/PlasmaPy.git

If you do not have git installed on your computer, then you may download the most recent source code from PlasmaPy’s GitHub repository by selecting “Clone or Download”, which will give you the option to download a zip file.

Note

The Contributing to PlasmaPy guide has instructions on how to fork a repository so that you may make pull requests.

Building and installing

In the top level directory, run

python setup.py install

or

pip install .

Testing a source code build

Testing PlasmaPy requires:

In the top level directory, run

python setup.py test

Building documentation

Building and testing PlasmaPy documentation requires the following packages:

To build the documentation, run the following command in the top level directory of the repository:

python setup.py build_docs

The HTML files built by this command will be placed in the docs/_build/html subdirectory and can be read using a web browser.