so I want to change my code file from the .py extension to .exe. Well after finishing to .exe when i try to opened there is error like this "the path doesn't exist" that's why can anyone explain? thank you in advance ????
error message :
Traceback (most recent call last):
File test.py, line 9, in <module>
File cvzone\HandTrackingModule.py, line 33, in __init__
File mediapipe\python\solutions\hands.py, line 114, in __init__
File mediapipe\python\solution_base.py, line 263, in __init__
FileNotFoundError: The path does not exist.
i use pyinstaller to convert python to executable file. The command is --onefile -w {script name}.
my code
from tkinter import Label
import cv2
from cvzone.HandTrackingModule import HandDetector
from cvzone.ClassificationModule import Classifier
import numpy as np
import math
capture = cv2.VideoCapture(0, cv2.CAP_DSHOW)
detector = HandDetector(maxHands=1)
Detector = HandDetector("C:/Users/W10/Documents/Handsign/cvzone/HandTrackingModule.py")
Classifier = Classifier("C:/Users/W10/Documents/Handsign/Model/keras_model.h5", "C:/Users/W10/Documents/Handsign/Model/labels.txt")
offset = 20
imgSize = 300
counter = 0
labels = ["A", "B", "C","D", "E", "Halo", "Aku", "Nama", "I", "F"]
while True:
success, img = capture.read()
imgOutput = img.copy()
hands, img = detector.findHands(img)
if hands:
hand = hands[0]
x, y, w, h = hand['bbox']
imgWhite = np.ones((imgSize, imgSize, 3), np.uint8) * 255
imgCrop = img[y - offset:y + h + offset, x - offset:x + w + offset]
imgCropShape = imgCrop.shape
aspectRatio = h / w
if aspectRatio > 1:
k = imgSize / h
wCal = math.ceil(k * w)
imgResize = cv2.resize(imgCrop, (wCal, imgSize))
imgResizeShape = imgResize.shape
wGap = math.ceil((imgSize - wCal) / 2)
imgWhite[:, wGap:wCal + wGap] = imgResize
prediction, index = Classifier.getPrediction(imgWhite, draw = False)
print(prediction, index)
else:
k = imgSize / w
hCal = math.ceil(k * h)
imgResize = cv2.resize(imgCrop, (imgSize, hCal))
imgResizeShape = imgResize.shape
hGap = math.ceil((imgSize - hCal) / 2)
imgWhite[hGap:hCal + hGap, :] = imgResize
prediction, index = Classifier.getPrediction(imgWhite, draw = False)
cv2.rectangle(imgOutput, (x - offset, y - offset-50), (x - offset+90, y - offset-50+50), (255, 0, 255), cv2.FILLED)
cv2.putText(imgOutput, labels[index], (x,y-30), cv2.FONT_HERSHEY_COMPLEX, 1.7,(255,255,255), 2)
cv2.rectangle(imgOutput,(x-offset,y-offset),(x+w+offset,y+h+offset),(255,0,255), 4)
cv2.imshow("ImageCrop", imgCrop)
cv2.imshow("ImageWhite", imgWhite)
cv2.imshow("Image", imgOutput)
cv2.waitKey(5)