# How to install pydicom

Note

We recommend installing into a virtual environment, which is an isolated Python environment that allows you to install packages without admin privileges. See the virtual environments tutorial on how to create and manage virtual environments.

## Install the official release

pydicom, being a Python library, requires Python. If you’re not sure whether or not your version of Python is supported, check this table.

### Install using pip

pydicom is available on PyPi, the official third-party Python software repository. The simplest way to install from PyPi is using pip with the command:

    pip install pydicom

You may need to use this instead, depending on your operating system:

    python -m pip install pydicom

You can also perform an offline installation by downloading and installing one of the release `*.whl` files. For example, with the v2.0 release:

    pip install pydicom-2.0.0-py3-none-any.whl

### Install using conda

pydicom is also available for conda at conda-forge:

    conda install -c conda-forge pydicom

### Downloading example/test DICOM files

To keep the package size small, a number of the larger DICOM files are not distributed with pydicom and are instead kept in the pydicom-data repository. To get the complete set of testing and example files you can either install the pydicom-data repository:

    pip install git+https://github.com/pydicom/pydicom-data

Or download the missing files to the local cache (after installing pydicom):

    python -c "import pydicom; pydicom.data.fetch_data_files()"

## Install the optional libraries

If you’re going to be manipulating pixel data then NumPy is required.

Using pip:

    pip install numpy

Through conda:

    conda install numpy

To decode JPEG compressed pixel data one or more additional libraries will need to be installed. See this page for a list of which library is needed to handle a given JPEG format, as specified by the dataset’s (0002,0010) Transfer Syntax UID value.

### Installing Pillow

Pillow is a popular Python imaging library that can handle the decompression of some JPEG and JPEG 2000 images.

Using pip; you may need to make sure that the libjpeg (for JPEG) and openjpeg (for JPEG 2000) libraries are installed beforehand:

    pip install pillow

Through conda:

    conda install -c conda-forge openjpeg jpeg
    conda install pillow

### Installing CharPyLS

CharPyLS is a Python interface to the CharLS C++ library and can decompress JPEG-LS images.

Using pip:

    pip install cython
    pip install git+https://github.com/Who8MyLunch/CharPyLS

Through conda:

    conda install cython
    pip install git+https://github.com/Who8MyLunch/CharPyLS

### Installing GDCM

GDCM is a C++ library for working with DICOM datasets that can decompress JPEG, JPEG-LS and JPEG 2000 images.

Using pip:

    pip install python-gdcm

Through conda:

    conda install gdcm -c conda-forge

### Installing pylibjpeg

pylibjpeg is a Python framework for decompressing JPEG, JPEG-LS, JPEG 2000 images and compressing or decompressing RLE images provided a suitable plugin is installed.

Using pip:

    pip install -U "pylibjpeg>=1.2" pylibjpeg-libjpeg pylibjpeg-openjpeg pylibjpeg-rle

## Install the development version

To install a snapshot of the latest code (the `master` branch) from GitHub:

    pip install git+https://github.com/pydicom/pydicom.git

The `master` branch is under active development and while it is usually stable, it may have undocumented changes or bugs.

If you want to keep up-to-date with the latest code, make sure you have Git installed and then clone the `master` branch (this will create a `pydicom` directory in your current directory):

    git clone --depth=1 https://github.com/pydicom/pydicom.git

Then install using pip in editable (`-e`) mode:

    pip install -e pydicom/

When you want to update your copy of the source code, run `git pull` from within the `pydicom` directory and Git will download and apply any changes.