analitics

Pages

Tuesday, May 20, 2025

Python : ... time-travel debugging project.

... ime-travel debugging, a technique that allows developers to "rewind" their code execution and inspect past states.
This is an old GitHub project from four years old.
  • Execution Recording – The debugger logs each step of execution, including variable states and function calls.
  • State Snapshots – It captures snapshots of memory at different points in execution.
  • Reverse Execution – Developers can step backward through the code to analyze previous states.
  • IDE Integration – Some tools integrate with VSCode and PyCharm for seamless debugging
This project is dependent on the following technologies:
  • Node.js / Express
  • Python 3
  • SQLite
  • better-sqlite3
  • Nearley.js / Moo.js
  • TypeScript
  • HTML5 Canvas
  • Webpack
  • gcc / automake
Unfortunately, the Time Traveling Debugger project has only been tested on OSX and Linux, and Windows support is not officially available

Sunday, May 18, 2025

Python 3.13.0 : bad management of python versions - need to fix into environment ...

I don't like how python management comes now, because some data god to \AppData\ and custom folder ... this will block some EXE because is not into environment ...
Will be more easy if the python team will make a management of all python on operating system area ... one reason is virtual environement , but this one python version of running ...
Can be better ? The management of python versions can be improved with simple user interface selection to manage all python versions and python modules, maybe a separate command shell more good thar python command on command shell, maybe a simple artificial intelligence just for user intercations and management of working ...
See this example , when I need to change to a lower version of python just to test some old python modules ...
Installing collected packages: tqdm, tifffile, scipy, rpds-py, platformdirs, opencv-python-headless, networkx, llvmlite, lazy-loader, imageio, attrs, scikit-image, referencing, pooch, numba, pymatting, jsonschema-specifications, jsonschema, rembg
   ----------------------------------------  0/19 [tqdm]  WARNING: The script tqdm.exe is installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   -- -------------------------------------  1/19 [tifffile]  WARNING: The scripts lsm2bin.exe, tiff2fsspec.exe, tiffcomment.exe and tifffile.exe are installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  WARNING: The scripts imageio_download_bin.exe and imageio_remove_bin.exe are installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. ----------
   ----------------------------------- ---- 17/19 [jsonschema]  WARNING: The script jsonschema.exe is installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
   ----------------------------------- ---- 17/19 [jsonschema]  WARNING: The script rembg.exe is installed in 'C:\Users\nicol\AppData\Roaming\Python\Python313\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed attrs-25.3.0 imageio-2.37.0 jsonschema-4.23.0 jsonschema-specifications-2025.4.1 lazy-loader-0.4 llvmlite-0.44.0 networkx-3.4.2 numba-0.61.2 opencv-python-headless-4.11.0.86 platformdirs-4.3.8 pooch-1.8.2 pymatting-1.1.14 referencing-0.36.2 rembg-2.0.66 rpds-py-0.25.0 scikit-image-0.25.2 scipy-1.15.3 tifffile-2025.5.10 tqdm-4.67.1

D:\PythonProjects\PyQt6\catafest_images_viewer>python main_001_removebk.py
Traceback (most recent call last):
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\main_001_removebk.py", line 4, in 
    from image_viewer import ImageViewer
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\image_viewer.py", line 7, in 
    from qt_setup import Image, ContextMenu, ProcessDialog, ProcessingManager, ImageProcessor
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\qt_setup.py", line 5, in 
    from processing import ProcessDialog, ProcessingManager, ImageProcessor
  File "D:\PythonProjects\PyQt6\catafest_images_viewer\processing.py", line 7, in 
    from rembg import remove
  File "C:\Users\nicol\AppData\Roaming\Python\Python313\site-packages\rembg\__init__.py", line 5, in 
    from .bg import remove
  File "C:\Users\nicol\AppData\Roaming\Python\Python313\site-packages\rembg\bg.py", line 7, in 
    import onnxruntime as ort
ModuleNotFoundError: No module named 'onnxruntime'

Sunday, May 11, 2025

Python Qt6 : simple animation with sprites.

Today I created with addon for Blender 3D and result is an image with sprites ...
I used that image with sprites and PyQt6 to animate my desktop screen, see the result:
This is the source code I used:
import sys
from PyQt6.QtWidgets import QApplication, QLabel, QWidget, QVBoxLayout, QMenu

# diff PyQt6 versus old PyQt
from PyQt6.QtGui import QAction

from PyQt6.QtGui import QPixmap, QIcon
from PyQt6.QtCore import QTimer, Qt

class AnimatedWindow(QWidget):
    def __init__(self):
        super().__init__()

        # set window
        self.setWindowFlags(Qt.WindowType.FramelessWindowHint | Qt.WindowType.WindowStaysOnTopHint)
        self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground)

        # build layout 
        layout = QVBoxLayout()
        self.label = QLabel(self)
        layout.addWidget(self.label)
        self.setLayout(layout)

        # load sprite sheet from Camera_256px.png file name
        sprite_sheet = QPixmap("Camera_256px.png")  
        self.frame_width = sprite_sheet.width() // 11  # because I have 11 sprite on image
        self.sprites = [sprite_sheet.copy(i * self.frame_width, 0, self.frame_width, sprite_sheet.height()) for i in range(11)]
        self.current_frame = 0

        # 
        self.timer = QTimer()
        self.timer.timeout.connect(self.update_animation)
        self.timer.start(150)  # Schimbă frame-ul la fiecare 150 ms

        # 
        self.resize(self.frame_width, sprite_sheet.height())

        # left down on screen 
        screen = QApplication.primaryScreen().geometry()
        self.move(10, screen.height() - self.height() - 10)

    def update_animation(self):
        """Actualizează sprite-ul în QLabel"""
        self.label.setPixmap(self.sprites[self.current_frame])
        self.current_frame = (self.current_frame + 1) % len(self.sprites)

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = AnimatedWindow()
    window.show()
    sys.exit(app.exec())

Thursday, May 8, 2025

Python 3.11.11 : Colab simple image to video with stabilityai - part 052.

Today, a simple test with artificial intelligence and stabilityai/stable-video-diffusion-img2vid-xt.
The result is not very good, but I believe the source code can be improved ...
pipe = StableVideoDiffusionPipeline.from_pretrained(
    'stabilityai/stable-video-diffusion-img2vid-xt',
    torch_dtype=torch.float16,
    variant='fp16'
)

pipe.enable_model_cpu_offload()
You can find the source code on my colab GitHUb projects - catafest_069.

Saturday, May 3, 2025

Python 3.13.3 : ... Nuitka package works with python 3.12 and MinGW.

Nuitka is licensed under the Apache License, Version 2.0; you may not use it except in compliance with the License.
Nuitka is the Python compiler. It is written in Python. It is a seamless replacement or extension to the Python interpreter and compiles every construct that Python 2 (2.6, 2.7) and Python 3 (3.4 - 3.13) have, when itself run with that Python version.
Nuitka translates the Python modules into a C level program that then uses libpython and static C files of its own to execute in the same way as CPython does.
I used the pip command:
python -m pip install -U nuitka
Collecting nuitka
  Downloading Nuitka-2.7.tar.gz (3.9 MB)
...
Successfully built nuitka
Installing collected packages: zstandard, ordered-set, nuitka
Successfully installed nuitka-2.7 ordered-set-4.1.0 zstandard-0.23.0

[notice] A new release of pip is available: 25.0.1 -> 25.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip
This version of python : 3.13.0rc1 not work !!!
I need to upgrade my version to 3.13.3 version today after I open an issue on github repo!
python.exe -m pip install --upgrade pip
...
Successfully installed pip-25.1.1

python -m nuitka --version
2.7
Commercial: None
Python: 3.13.0rc1 (tags/v3.13.0rc1:e4a3e78, Jul 31 2024, 20:58:38) [MSC v.1940 64 bit (AMD64)]
Flavor: CPython Official
GIL: yes
Executable: C:\Python313\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 10
Nuitka-Scons:WARNING: Windows SDK must be installed in Visual Studio for it to be usable
Nuitka-Scons:WARNING: with Nuitka. Use the Visual Studio installer for adding it.
Version C compiler: ~\AppData\Local\Nuitka\Nuitka\Cache\downloads\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2\mingw64\bin\gcc.exe (gcc 14.2.0).
After upgrade the nuitka show me these results:
python -m nuitka --version
2.7
Commercial: None
Python: 3.13.3 (tags/v3.13.3:6280bb5, Apr  8 2025, 14:47:33) [MSC v.1943 64 bit (AMD64)]
Flavor: CPython Official
GIL: yes
Executable: C:\Python313\python.exe
OS: Windows
Arch: x86_64
WindowsRelease: 10
Nuitka-Scons:WARNING: Windows SDK must be installed in Visual Studio for it to be usable
Nuitka-Scons:WARNING: with Nuitka. Use the Visual Studio installer for adding it.
Version C compiler: ~\AppData\Local\Nuitka\Nuitka\Cache\downloads\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2\mingw64\bin\gcc.exe (gcc 14.2.0).
Same error, I uninstall the Python: 3.13.3 version and I install the python version 3.13.0 and use the pip again to install this python package.
python -m pip install -U nuitka
Collecting nuitka
...
Installing collected packages: zstandard, ordered-set, nuitka
Successfully installed nuitka-2.7 ordered-set-4.1.0 zstandard-0.23.0

[notice] A new release of pip is available: 24.2 -> 25.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip
python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in c:\python_3_13_0\lib\site-packages (24.2)
...
Successfully installed pip-25.1.1
Using this version tell me same error with Windows and Visual Studio, but the MinGW is install from the first version.
The solution from artificial intelligence is to use another python version.
I used these commands:
py -3.12 -m pip install -U nuitka
Collecting nuitka
  Using cached Nuitka-2.7.tar.gz (3.9 MB)
  Installing build dependencies ... done
  ...
  Installing collected packages: zstandard, ordered-set, nuitka
Successfully installed nuitka-2.7 ordered-set-4.1.0 zstandard-0.23.0

[notice] A new release of pip is available: 24.2 -> 25.1.1
[notice] To update, run: C:\Python312\python.exe -m pip install --upgrade pip
py -0
 -V:3.13 *        Python 3.13 (64-bit)
 -V:3.12          Python 3.12 (64-bit)
py -3.12 -m nuitka --mingw64 hello.py
Nuitka-Options: Used command line options:
Nuitka-Options:   --mingw64 hello.py
Nuitka-Options:WARNING: You did not specify to follow or include anything but main
Nuitka-Options:WARNING: program. Check options and make sure that is intended.
Nuitka: Starting Python compilation with:
Nuitka:   Version '2.7' on Python 3.12 (flavor 'CPython Official')
Nuitka:   commercial grade 'not installed'.
Nuitka: Completed Python level compilation and optimization.
Nuitka: Generating source code for C backend compiler.
Nuitka: Running data composer tool for optimal constant value handling.
Nuitka: Running C compilation via Scons.
Nuitka-Scons: Backend C compiler: gcc (gcc 14.2.0).
Nuitka-Scons: Backend C linking with 6 files (no progress information available for
Nuitka-Scons: this stage).
Nuitka-Scons: Compiled 6 C files using ccache.
Nuitka-Scons: Cached C files (using ccache) with result 'cache miss': 6
Nuitka: Keeping build directory 'hello.build'.
Nuitka: Successfully created 'D:\PythonProjects\hello.exe'.
Nuitka: Execute it by launching 'hello.cmd', the batch file needs to set environment.
The test is a simple python script from the official website:
def talk(message):
    return "Talk " + message

def main():
    print(talk("Hello World"))

if __name__ == "__main__":
    main()
... and this python version works well with MinGW, the artificial intelligence used to fix these errors was ChatGPT.
hello.exe
Talk Hello World