本文介绍了如何修复python 3.7中的“没有名为vidcap的模块"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了摄像头,效果很好.问题是,当我尝试导入 pygame 时出现 ModuleNotFoundError.(注:我用的是windows)

I have camera set up, which works fine. The thing is, there is an ModuleNotFoundError when I am trying to import pygame.(Note:I am using windows)

这是一个测试项目,我必须用pygame制作一个相机.我试过一些 youtube 教程,但我弄乱了 pygame,但它总是导致错误.

This is a test project, and I have to make a camera out of pygame. I've tried some youtube tutorials and I messed with pygame but it always causes an Error.

这是我目前所拥有的:

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

每次尝试都出现相同的错误.错误信息是:

I resulted in the same error every time I tried.The Error message is:

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'

有什么建议吗?

推荐答案

您似乎使用的是 Windows.所以你需要为 pygame.camera 安装 VideoCapture 模块.一个简单的方法是从这里(基于在您的 Python 版本上)并使用 pip 安装它:

It seems that you are using Windows. So you need to install VideoCapture module for the pygame.camera. An easy way is to grab the prebuilt wheel package from here (based on your Python version) and install it with pip:

pip install VideoCapture‑0.9.5‑cp37‑cp37m‑win32.whl

这应该可以修复 ModuleNotFoundError.

这篇关于如何修复python 3.7中的“没有名为vidcap的模块"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 15:59