Describe the bug
When using Katna's Video class to extract keyframes on Windows with Python 3.12, the process crashes with errors related to:
RuntimeError: CPU dispatcher tracer already initialized
AttributeError: module 'numpy' has no attribute 'ndarray'
These errors occur even with proper virtual memory settings and 64GB physical RAM available. The issue persists despite attempts to:
- Use
if __name__ == "__main__" guard
- Downgrade Python (tested with 3.10/3.11)
- Reinstall dependencies (numpy, opencv-python, imagecodecs)
Expected behavior
Keyframe extraction should complete without multiprocessing-related initialization conflicts.
Environment
- OS: Windows 10/11 (both tested)
- Python: 3.12.0 (64-bit), 3.10.13 (64-bit)
- Katna: 1.0.0 (latest pip version)
- Dependencies:
- numpy 2.0.1
- opencv-python 4.8.0.76
- imagecodecs 2023.7.21
Error logs
Traceback (most recent call last): File "D:\KSFrame\KFramesAnalyzer.py", line 1, in <module> from Katna.video import Video File "D:\Python\Python312\Lib\site-packages\Katna\video.py", line 11, in <module> import numpy as np File "D:\Python\Python312\Lib\site-packages\numpy_init_.py", line 692, in <module> _core.getlimits._register_known_types() File "D:\Python\Python312\Lib\site-packages\numpy_core\getlimits.py", line 236, in _register_known_types float128_ma = MachArLike(ld, ^^^^^^^^^^^^^^ ... [truncated for brevity] AttributeError: module 'numpy' has no attribute 'ndarray'
Code to reproduce
python from Katna.video import Video
from Katna.writer import KeyFrameDiskWriter
if name == "main":
FE = Video()
writer = KeyFrameDiskWriter(location="selectedframes")
FE.extract_video_keyframes(3, "test.mp4", writer) # Crashes here
Potential root cause
- Multiprocessing conflict: Katna's internal use of multiprocessing spawns new processes that re-import modules, causing numpy's C-extensions to fail initialization.
- NUM_WORKERS limitation: Setting
Katna.config.NUM_WORKERS = 1 doesn't fully disable multiprocessing logic in Windows.
- Python 3.12 compatibility: Potential incompatibility with numpy 2.x series and C-extension initialization on Windows.
AI used for proper expression
Describe the bug
When using Katna's
Videoclass to extract keyframes on Windows with Python 3.12, the process crashes with errors related to:RuntimeError: CPU dispatcher tracer already initializedAttributeError: module 'numpy' has no attribute 'ndarray'These errors occur even with proper virtual memory settings and 64GB physical RAM available. The issue persists despite attempts to:
if __name__ == "__main__"guardExpected behavior
Keyframe extraction should complete without multiprocessing-related initialization conflicts.
Environment
Error logs
Traceback (most recent call last): File "D:\KSFrame\KFramesAnalyzer.py", line 1, in <module> from Katna.video import Video File "D:\Python\Python312\Lib\site-packages\Katna\video.py", line 11, in <module> import numpy as np File "D:\Python\Python312\Lib\site-packages\numpy_init_.py", line 692, in <module> _core.getlimits._register_known_types() File "D:\Python\Python312\Lib\site-packages\numpy_core\getlimits.py", line 236, in _register_known_types float128_ma = MachArLike(ld, ^^^^^^^^^^^^^^ ... [truncated for brevity] AttributeError: module 'numpy' has no attribute 'ndarray'Code to reproduce
Potential root cause
Katna.config.NUM_WORKERS = 1doesn't fully disable multiprocessing logic in Windows.AI used for proper expression