How to install pydicom¶
We recommend installing into a virtual environment, which is an isolated Python environment that allows you to install packages without admin privileges.
Install the official release¶
Install using pip¶
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¶
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.
pip install numpy
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.
Pillow is a popular Python imaging library that can handle the decompression of some JPEG and JPEG 2000 images.
pip install pillow
conda install -c conda-forge openjpeg jpeg conda install pillow
pip install pyjpegls
conda install cython pip install git+https://github.com/pydicom/pyjpegls
GDCM is a C++ library for working with DICOM datasets that can decompress JPEG, JPEG-LS and JPEG 2000 images.
pip install python-gdcm
The wheels available through conda-forge tend to be older versions and not as well supported. They’re available on conda using:
conda install gdcm -c conda-forge
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.
pip install -U pylibjpeg[all]
Install the development version¶
To install a snapshot of the latest code (the
main branch) from
pip install git+https://github.com/pydicom/pydicom
main 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
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 (
pip install -e pydicom/
When you want to update your copy of the source code, run
git pull from
pydicom directory and Git will download and apply any changes.