3

The error message:

In [1]:

import pydicom as dicomio
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-102814c2908e> in <module>()
----> 1 import pydicom as dicomio

ImportError: No module named pydicom

To install pydicom I used

conda skeleton pypi pydicom
conda build pydicom

Then uploaded to binstar and used conda install -c to download and install it again. It can now be seen in the anaconda environment.

Lindas-iMac:~ iMacLinda$ conda list -e | grep pydi
pydicom=0.9.9=py27_0

Thank you for your help.

Suever
  • 64,497
  • 14
  • 82
  • 101
Linda Marsh
  • 105
  • 1
  • 1
  • 9

4 Answers4

5

The pydicom package is importable as dicom until version 0.9.9. The documentation on read the docs is for the unreleased master branch version 1.0, in which the package name has changed to pydicom.

Thus, try importing pydicom as:

import dicom

If you need to read a file, you can use the command:

ds = dicom.read_file('filename.dcm')

Once pydicom 1.0 is released, you can follow the wiki page for porting instructions.

bastula
  • 181
  • 2
  • 13
2

You can us pip:

pip install pydicom

Conda works with pip.

Mike Müller
  • 82,630
  • 20
  • 166
  • 161
  • 1
    Thanks for your answer. However it did not work. I still have the same problem. – Linda Marsh Nov 01 '15 at 19:46
  • Did `pip` actually install it? – Mike Müller Nov 01 '15 at 20:26
  • This is what happened. Lindas-iMac:~ iMacLinda$ pip install pydicom Requirement already satisfied (use --upgrade to upgrade): pydicom in ./anaconda/lib/python2.7/site-packages – Linda Marsh Nov 02 '15 at 08:07
  • I have now done 'conda uninstall pydicom'. Then 'pip uninstall pydicom', Then 'pip install pydicom'. I got a message saying install successful. I can now see pydicom if I do 'conda list', but not if I use the option '-e'. Python still cannot see the module. – Linda Marsh Nov 02 '15 at 08:24
  • The `-e` is just for exporting the package list. This does not work with pip-installed packages. Does `pydicom` import in Python now? – Mike Müller Nov 02 '15 at 08:40
1

If you use pydicom version < 1.0 then you should use import dicom. But if you use pydicom version >= 1.0 then you should install dicom first, then you can import pydicom.

Mawanda
  • 61
  • 6
0

Thanks again for your reply Mike.

The information published at http://www.pydicom.readthedocs.org seems to be incorrect. I have just found some alternative documentation at http://www.pyscience.wordpress.com Pydicom can be imported within python as dicom and not as pydicom:

>>>import dicom as dicomio

This seemed to work.

Linda Marsh
  • 105
  • 1
  • 1
  • 9