Closed suever closed 9 years ago
From darcymason@gmail.com on May 28, 2010 16:46:15
By 'it does not work' on the import, do you get the error, 'No module named dicom'? If it is some other error, please post it.
I'm not an Eclipse user, but if the error is "no module named dicom", then I suspect this is related to python's path, or with the version of python being used. Are the python versions's the same? (can check on interpreter startup or with sys.version).
If they are using different versions of python, then pydicom will need to be re-installed for the Eclipse version of python.
If the python versions are the same, then maybe comparing sys.path of the two would help. Check if pydicom (as folder 'dicom'') is in one of the locations in sys.path (it normally installs to python's usual site-packages directory).
Hope that helps Darcy
From tomek.ce...@gmail.com on May 29, 2010 02:00:27
Hello Darcy!
Thank you for prompt response! The python interpreter is the same in presented description:
Python shell:
import sys sys.version '2.6.2 ( r262 :71600, Sep 18 2009, 10:06:20) \n[GCC 4.2.1 20070719 [FreeBSD]]'
2.6.2 ( r262 :71600, Sep 18 2009, 10:06:20) [GCC 4.2.1 20070719 [FreeBSD]]
It looks that the shell interpreter can see and access the dicom module components, while PyDev does not:
1.Python shell:
import dicom dir(dicom) ['ReadFile', 'UID', 'WriteFile', '_UID_dict', 'builtins', 'doc', 'file', 'name', 'package', 'path', '_dicom_dict', 'charset', 'datadict', 'dataelem', 'dataset', 'debug', 'filebase', 'filereader', 'filewriter', 'formatter', 'handler', 'logger', 'logging', 'sequence', 'tag', 'valuerep']
- For this code in Eclipse PyDev I get nothing. When I try to rad file with code: import dicom file=dicom.filereader.ReadFile("../data/test.dcm")
I get following traceback:
Traceback (most recent call last):
File "/mnt/stuff/cederom/moje/eclipse/dicomtagslayer/dicomtagslayer/src/dicom.py",
line 4, in
Here goes the directory structure of the installed package:
%find /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/ -type d /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/ /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/EGG-INFO /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom/doc /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom/examples /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom/test /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom/testcharsetfiles /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom/testfiles /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom/util
When I set the PYTHONPATH to /usr/local/lib/python2.6/site-packages/pydicom-0.9.2- py2.6.egg/ and /usr/local/lib/python2.6/site-packages/pydicom-0.9.2-py2.6.egg/dicom nothing changes.
Maybe someone had this problem before and know working solution? :-)
Best regards, Tomek Cedro
From tomek.ce...@gmail.com on May 29, 2010 03:20:52
Hahahaha!!! I am new to Python, so I made a silly mistake - in my project I have named "dicom.py" a module responsible for dicom operations, while this file was trying to include system wide "dicom" module - local path won, so it was impossible to import PyDicom. I have renamed my file into "dcm.py" and everything works fine! Thank you and sorry for false alert! :-)
From darcymason@gmail.com on May 29, 2010 07:25:12
Ah. The way python's import works makes it easy for these kinds of things to happen, unfortunately. Glad you were able to find the solution.
Status: Done
From tomek.ce...@gmail.com on May 28, 2010 17:15:40
What steps will reproduce the problem? 1. Install PyDicom (I am using FreeBSD 8.0, package is called py26-pydicom)
Original issue: http://code.google.com/p/pydicom/issues/detail?id=86