Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failure in pixel_data_handlers\pylibjpeg_handler #56

Closed
giveinput opened this issue Feb 3, 2021 · 2 comments
Closed

failure in pixel_data_handlers\pylibjpeg_handler #56

giveinput opened this issue Feb 3, 2021 · 2 comments

Comments

@giveinput
Copy link

The problem
I'm trying to read a dicom-file, which is in JPEG Lossless syntax. Therefor I need the pylibjpeg-libjpeg module, which causes an error in the import from pydicom:

AttributeError: partially initialized module 'pydicom' has no attribute 'config' (most likely due to a circular import)

Full traceback:
Traceback (most recent call last): File "read_and_show_dicom.py", line 6, in <module> import pydicom File "C:\...\env38\lib\site-packages\pydicom\__init__.py", line 32, in <module> from pydicom.dataelem import DataElement File "C:\...\env38\lib\site-packages\pydicom\dataelem.py", line 18, in <module> from pydicom import config # don't import datetime_conversion directly File "C:\...\env38\lib\site-packages\pydicom\config.py", line 238, in <module> import pydicom.pixel_data_handlers.pylibjpeg_handler as pylibjpeg_handler # noqa File "C:\...\env38\lib\site-packages\pydicom\pixel_data_handlers\pylibjpeg_handler.py", line 59, in <module> import pylibjpeg File "C:\...\env38\lib\site-packages\pylibjpeg\__init__.py", line 38, in <module> add_handler() File "C:\...\env38\lib\site-packages\pylibjpeg\utils.py", line 24, in add_handler if handler not in pydicom.config.pixel_data_handlers: AttributeError: partially initialized module 'pydicom' has no attribute 'config' (most likely due to a circular import)

My environment
Output for: python -m pydicom.env_info

module version
platform Windows-10-10.0.19041-SP0
Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:43:54) [MSC v.1928 32 bit (Intel)]
pydicom 2.1.2
gdcm module not found
jpeg_ls module not found
numpy 1.19.5
PIL 8.1.0

My imports

from tkinter import *
from tkinter.ttk import *
import cv2
import numpy as np
import pydicom  
from PIL import ImageTk, Image
@darcymason
Copy link
Member

Below, just simplifying the trace a little bit to make it easier to follow:

File "read_and_show_dicom.py", 
import pydicom 

File "...\pydicom\__init__.py", line 32, 
from pydicom.dataelem import DataElement 

File "...\pydicom\dataelem.py", line 18, in <module> 
from pydicom import config 

File "...\pydicom\config.py", line 238, in <module> 
import pydicom.pixel_data_handlers.pylibjpeg_handler as pylibjpeg_handler 

File "...\pydicom\pixel_data_handlers\pylibjpeg_handler.py", line 59, in <module> 
import pylibjpeg

File "...\pylibjpeg\__init__.py", line 38, in <module> 
add_handler() 

File "...\pylibjpeg\utils.py", line 24, in add_handler 
if handler not in pydicom.config.pixel_data_handlers: 

AttributeError: partially initialized module 'pydicom' has no attribute 'config' (most likely due to a circular import)

I'm wondering whether this would be okay if you imported pylibjpeg first before pydicom in the user code? However, pylibjpeg examples show importing pydicom first. Maybe @scaramallion can comment.

@scaramallion
Copy link
Member

Hmm, with the latest pydicom you shouldn't need to import pylibjpeg manually, so I'd try removing that first. I'll take a look when I get a chance.

@scaramallion scaramallion transferred this issue from pydicom/pydicom Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants