2

After having installed libgdcm-tools (2.6.6-3) on my system (via apt install libgdcm-tools) I am not longer able to import pydicom in Python. When running import pydicom as pdc I got the following error

AttributeError: module 'gdcm' has no attribute 'DataElement'.

Removing libgdcm-tools does not solve the issue.

I am working with Python 3.7 and pydicom 2.0.0 in Ubuntu 18.04.

fednem
  • 95
  • 2
  • 13
  • pydicom detects the availability of `gdcm` by trying `import gdcm`. My guess is that this succeeds after installing `libgcdm-tools`, even if `gdcm` itself is not installed, and fails on accessing it. If removing `libgdcm-tools` does not fix this, the removal is probably incomplete (try `import gdcm` in a Python console). – MrBean Bremen Jul 16 '20 at 12:42
  • I would suggest you write an issue in pydicom - this can probably be fixed by a better check for gdcm. – MrBean Bremen Jul 16 '20 at 12:43
  • Funnily enough I had this same problem recently, only I didn't have gdcm installed. What I did have was a subdirectory called `gdcm` in my working directory... – scaramallion Jul 16 '20 at 22:47
  • @scaramallion - hah, you are right - you can import a directory even if it doesn't have an `__init.py__` in there - it is imported as a namespace in this case. Probably something to consider if checking for existing modules... and it explains the problem. – MrBean Bremen Jul 17 '20 at 04:46

1 Answers1

0

Indeed @scaramallion's comment pointed me in the right direction. I didnt't have a gcdm directory in the working directory, but in my home directory. Removing that directory solved the problem.

fednem
  • 95
  • 2
  • 13