【发布时间】:2019-11-13 01:15:16
【问题描述】:
我设置了摄像头,效果很好。问题是,当我尝试导入 pygame 时出现 ModuleNotFoundError。 (注:我用的是windows)
这是一个测试项目,我必须用pygame制作一个相机。我已经尝试了一些 youtube 教程,但我搞砸了 pygame,但它总是会导致错误。
这是我目前所拥有的:
import pygame.camera
pygame.camera.init()
camera = pygame.camera.list_cameras()[0]
pyg = pygame.camera.Camera(camera (640, 480), 'HSV')
--snip--
if pyg.query_image():
win.blit(pyg.get_image(surface=win), (0, 0))
pygame.quit()
我每次尝试都会导致相同的错误。 错误信息是:
Traceback (most recent call last):
File "C:\Users\roche\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\_camera_vidcapture.py", line 31, in init
import vidcap as vc
ModuleNotFoundError: No module named 'vidcap'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\roche\Documents\pygame_camera.py", line 5, in <module>
pygame.camera.init()
File "C:\Users\roche\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\camera.py", line 68, in init
_camera_vidcapture.init()
File "C:\Users\roche\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pygame\_camera_vidcapture.py", line 33, in init
from VideoCapture import vidcap as vc
ModuleNotFoundError: No module named 'VideoCapture'
有什么建议吗?
【问题讨论】:
-
您好,请让我们看看完整的错误 - ModuleNotFoundError 表明您没有安装任何东西。
-
这是最小的工作示例吗?换句话说,这是导致相同错误的绝对最小代码量吗?如果没有,请删除无关代码。
-
编辑:我添加了错误信息并删除了一些代码
-
赏金或回答任何人???
-
你在用linux吗?
标签: python python-3.x pygame