Transition to pydicom 1.x¶
Important information on differences in pydicom post 1.0 vs pre-1.0
As is often the case for major software version number changes, pydicom 1.0 breaks with the previous release of pydicom (0.9.9) in several ways. These require changes to user code to target the pydicom >= 1.0 package, or to check and deal with the differences between the versions.
Backwards-incompatible changes post 1.0
the library is no longer
pydicom, to match the package name
short-form names such as
Beamsare no longer allowed; use the full keyword e.g.
some less-used modules within pydicom have been renamed, e.g.
Why was the package name changed? There are several reasons for this change:
it is standard Python practice for the package and the installed library to have the same name
first-time users expect to be able to type
import pydicomrather than
import dicom, which has caused confusion
it makes sense for search engines - with the correct name it is much easier to find relevant questions and example code online
The decision wasn’t taken lightly, but with a great deal of discussion on the GitHub issues list. Having made the leap, the rest of this guide should help smooth the way…
Error messages relating to the pydicom transition¶
This section is here in the hopes of people getting directed to this page on searches. If that’s you, then welcome! Hopefully the information here can get things going quickly for you.
For those with pydicom < 1.0 installed, on trying to import pydicom, they will get an ImportError message:
>>> import pydicom Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named pydicom
Your choice then is to update to pydicom >=1.0 (see Installing pydicom
section), or to instead use
import dicom and follow the old-style pydicom
Conversely, if pydicom >= 1.0 is installed, the error message for
dicom will look like:
>>> import dicom Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named dicom
In this case you likely have installed pydicom >= 1.0, and so the
does not exist. You can simply
import pydicom instead, and continue with
the new pydicom, or, if you really need the old pydicom, then you should:
pip install dicom
and you should be good to go.
API Changes in version 1.0¶
Apart from the change of the package name, there are some changes in module names, class names, and behavior that may require some code changes.
Changed module names¶
Changed function and variable names¶
dcmread()(but old name remains for compatibility)
dcmwrite()(but old name remains for compatibility)
tag_in_exception()has been moved to
UID.is_valid()is now a property
Removed functions and names¶
support for old names (before DICOM keywords) in module
datadictis gone (
filereader.not_group2()is no longer available
uid.pydicom_UIDshas been removed
TransferSyntaxUIDnot added automatically to