【问题标题】:webcam on py2exe doesn't work correctlypy2exe 上的网络摄像头无法正常工作
【发布时间】:2017-08-26 17:14:46
【问题描述】:

您好,我编写了一个使用网络摄像头的程序,但是当我通过 py2exe 制作 exe 它因为这个错误而崩溃。

error:

这是我的代码

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()

谢谢:)

【问题讨论】:

    标签: python windows pygame webcam py2exe


    【解决方案1】:

    不确定这是否可行(我无法让 python 代码在我的计算机上运行),但您是否尝试过 pyinstaller 而不是 Py2Exe (http://pyinstaller.org)?

    【讨论】:

    • 我测试了这个,但它有同样的问题
    【解决方案2】:

    大家好,我终于可以用 cx_freeze 制作一个可执行文件了 可以与相机一起使用的 解决方案是您应该将 vidcapture.pyd 复制到包含您的程序的文件中

    this picture is my file that have vidcapture.pyd

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多