简体   繁体   中英

webcam on py2exe doesn't work correctly

Hi I write a program for using webcam but when I make it exe by py2exe it crash because of this error.

error:

and this is my code

import pygame.camera
import pygame.image
import sys
pygame.camera.init()
cameras = pygame.camera.list_cameras()


webcam = pygame.camera.Camera(cameras[0])

webcam.start()

 # grab first frame
img = webcam.get_image()

WIDTH = img.get_width()
HEIGHT = img.get_height()

screen = pygame.display.set_mode( ( WIDTH, HEIGHT ) )
pygame.display.set_caption("pyGame Camera View")

while True :
    for e in pygame.event.get() :
        if e.type == pygame.QUIT :
            sys.exit()

     # draw frame
    screen.blit(img, (0,0))
    pygame.display.flip()
     # grab next frame    
    img = webcam.get_image()

thanks :)

不知道这是否行得通(我无法在计算机上运行python代码),但是您是否尝试过pyinstaller而不是Py2Exe( http://pyinstaller.org )?

Hey guys i finally can make an executable file with cx_freeze which that can work with camera and the solution is you should to copy vidcapture.pyd into your file that have your program

this picture is my file that have vidcapture.pyd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM