I need help with my python turtle program

Question:
so, i wanted to make a code that will open a opening video
for my ‘os’ and i asked chatGPT how to do it and then there were errors the whole time and i send the most recent call to chat gpt and it said i need to send something on the shell, then in bash, and the whole time there are fails and it wont even work without saying: “traceback (most recent call last):” LIKE BTCH

Repl link:
https://replit.com/@emka4LIFEEE/delta-C (if it is the wrong link someone reply pls :upside_down_face:)

import tkinter as tk
from tkinter import ttk
import cv2

video_path = "opening.MOV"

def play_video():
    cap = cv2.VideoCapture(video_path)

    while cap.isOpened():
        ret, frame = cap.read()

        if not ret:
            break

        frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        img = tk.PhotoImage(width=cap.get(3), height=cap.get(4))
        img.put("#%02x%02x%02x" % (0, 0, 0), (0, 0, cap.get(3), cap.get(4)))
        img = ttk.PhotoImage(file=frame)
        label.config(image=img)
        label.image = img
        root.update()

    cap.release()

root = tk.Tk()
root.title("Video Player")

label = ttk.Label(root)
label.pack()

play_button = ttk.Button(root, text="Play Video", command=play_video)
play_button.pack()

root.mainloop()

COMING BACK TODAY 20:45
(hope there are reply’s)

oh btw the message its sending me is;

Traceback (most recent call last):
  File "/home/runner/delta-C/main.py", line 3, in <module>
    import cv2
  File "/home/runner/delta-C/.pythonlibs/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
    bootstrap()
  File "/home/runner/delta-C/.pythonlibs/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
    native_module = importlib.import_module("cv2")
  File "/nix/store/xf54733x4chbawkh1qvy9i1i4mlscy1c-python3-3.10.11/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

You are missing libGL, a library package. You will need to use nix to install libGL.

1 Like

and how would I do that?

ok i tried and it didnt work too

You are importing cv2, which is a package that needs extra configuration.
So, use the template for it: https://replit.com/@NuclearPasta0/OpenCV-Python

2 Likes