numpy Cv2安装不工作,以及其他问题

xxls0lw8  于 2023-04-21  发布在  其他
关注(0)|答案(1)|浏览(146)

我将pygame项目导出为.exe文件,当我运行它时,我得到了一个错误。我发现,由于this和其他帖子,我代码中的多个内容都显示为“无”,并且可能不支持我的文件类型。

cap = cv2.VideoCapture("C:/Users/Molly/OneDrive/Desktop/New folder (2)/VIDEOOO.mp4")

success, img = cap.read()
shape = img.shape[1::-1]
wn = pygame.display.set_mode(shape)
clock = pygame.time.Clock()

我做了那篇文章所说的,它是,事实上,不支持。并重新安装cv2。然后我在我的终端中得到了这个错误:

building library "npymath" sources
        No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
        error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
        [end of output]

        note: This error originates from a subprocess, and is likely not a problem with pip.
      error: legacy-install-failure

      Encountered error while trying to install package.

      numpy

      note: This is an issue with the package mentioned above, not pip.
      hint: See above for output from the failure.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

我该怎么解决?我做的对吗?

8yoxcaq7

8yoxcaq71#

安装Microsoft C++生成工具:转到以下链接并下载“Build Tools for Visual Studio 2019”安装程序:https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019
运行安装程序:下载安装程序后,运行它并按照说明安装构建工具。
尝试再次安装numpy:安装构建工具后,尝试使用pip再次安装numpy。如果错误消息仍然存在,请尝试以管理员权限运行pip安装命令(例如,在Linux/Mac上运行“sudo pip install numpy”,或在Windows上以管理员身份运行命令提示符)。

相关问题