Unable to use DICOMUtils to load dicom files

I am trying use the below sample code from vscode , but getting the error captured below.
from DICOMLib import DICOMUtils
with DICOMUtils.TemporaryDICOMDatabase() as db:
DICOMUtils.importDicom(dicomDataDir, db)
patientUIDs = db.patients()
for patientUID in patientUIDs:
loadedNodeIDs.extend(DICOMUtils.loadPatientByUID(patientUID))

Error
No module named ‘logic’
3.9.10 (main, Jan 23 2025, 23:04:06) [MSC v.1942 64 bit (AMD64)]
Traceback (most recent call last):
File “c:\Users\praveen.selvaraj\Downloads\Slicer-5.6.2-Win\bin\import sys.py”, line 10, in
from DICOMLib import DICOMUtils
File “C:\Users\praveen.selvaraj\AppData\Local\slicer.org\Slicer 5.8.0\lib\Slicer-5.8\qt-scripted-modules\DICOMLib_init_.py”, line 1, in
from .DICOMProcesses import *
File “C:\Users\praveen.selvaraj\AppData\Local\slicer.org\Slicer 5.8.0\lib\Slicer-5.8\qt-scripted-modules\DICOMLib\DICOMProcesses.py”, line 38, in
class DICOMProcess:
File “C:\Users\praveen.selvaraj\AppData\Local\slicer.org\Slicer 5.8.0\lib\Slicer-5.8\qt-scripted-modules\DICOMLib\DICOMProcesses.py”, line 84, in DICOMProcess
def start(self, cmd: str, args: list[str]) → qt.QProcess:
AttributeError: module ‘qt’ has no attribute ‘QProcess’

The DICOM module is set up to work in the Slicer environment, not other python environments. If you want to dig into the code it’s likely that a large part could be factored out.

Thank you pieper. So I am looking to automate manual segmentation , so It is recommended and potentially possible(without refactor) only from slicer python console ?

If you want to use Slicer’s features for now you need to use Slicer’s python environment, which you can do with --no-main-window and specify a python script. If you want to factor out some features to use outside of Slicer you can, but it means doing some coding work. Slicer’s python is basically just python, but with extra features enabled to support the GUI app.