On Dec 15, 3:19 am, MasatoDicom <
amirkom...@gmail.com> wrote:
> I recently installed "pydicom" and got the following error while
> trying to read a dicom file. The dicom file is present inside the
> "testfiles" folder that is installed under site-packages/dicom/ folder
> while installing "pydicom".
>
> ...
> >>> import dicom
> >>> ds=dicom.read_file("CT_small.dcm")
>
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> ds=dicom.read_file("CT_small.dcm")
> File "C:\Python27\lib\site-packages\dicom\filereader.py", line 460,
> in read_file
> fp = open(fp, 'rb')
> IOError: [Errno 2] No such file or directory: 'CT_small.dcm'
>
It's probably just a case of needing to change the working directory:
>>> import os
>>> os.getcwd() # to see where you are
>>> os.chdir('<path-to-testfiles>') # to change directory
or, can open the file with a full path; in your case it should be
>>> dicom.read_file(r"c:\Python27\lib\site-packages\dicom\testfiles\CT_small.dcm")
The examples from the pydicom website assume the working directory is
the testfiles directory.
-Darcy