Importerror:错误:在“ CV2”的加载过程中检测到递归。二进制扩展。检查OpenCV安装
我是与Python一起制作屏幕录音机,我正在使用Python的OpenCV,但它给出了我在任何地方都找不到工作答案的输出,我真的需要帮助。我只使用Python大约一年了。这是它给我的输出:
['C:\\Users\\Diana\\Desktop\\python\\RecScreen', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\DLLs', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\pygooglevoice-0.5-py3.10.egg', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\Pythonwin']
Traceback (most recent call last):
File "C:\Users\Diana\Desktop\python\RecScreen\RecScreen.py", line 3, in <module>
import cv2
File "C:\Users\Diana\AppData\Local\Programs\Python\Python310\lib\cv2\__init__.py", line 180, in <module>
bootstrap()
File "C:\Users\Diana\AppData\Local\Programs\Python\Python310\lib\cv2\__init__.py", line 75, in bootstrap
raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.
我的代码是:
# importing the required packages
import pyautogui
import cv2
import keyboard
import numpy as np
# Specify resolution
resolution = (1920, 1080)
# Specify video codec
codec = cv2.VideoWriter_fourcc(*"XVID")
# Specify name of Output file
filename = "Recording.avi"
# Specify frames rate. We can choose any
# value and experiment with it
fps = 60.0
# Creating a VideoWriter object
out = cv2.VideoWriter(filename, codec, fps, resolution)
cv2.namedWindow("Recording", cv2.WINDOW_NORMAL)
cv2.resizeWindow("Recording", 480, 270)
while True:
# Take screenshot using PyAutoGUI
img = pyautogui.screenshot()
# Convert the screenshot to a numpy array
frame = np.array(img)
# Convert it from BGR(Blue, Green, Red) to
# RGB(Red, Green, Blue)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Write it to the output file
#out.write(frame)
# Optional: Display the recording screen
cv2.imshow('Live', frame)
# Stop recording when we press 'ctrl+esc'
if keyboard.is_pressed("Ctrl+esc"):
break
# Release the Video writer
out.release()
# Destroy all windows
cv2.destroyAllWindows()
我不知道如何解决此错误。任何帮助都将受到赞赏。
I as making a screen recorder with python and I was using OpenCV with python but its giving this output that I can't find a working answer ANYWHERE and I really need help. I am have only been using python for about a year. Here is the output it gives me:
['C:\\Users\\Diana\\Desktop\\python\\RecScreen', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\DLLs', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\pygooglevoice-0.5-py3.10.egg', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32\\lib', 'C:\\Users\\Diana\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\Pythonwin']
Traceback (most recent call last):
File "C:\Users\Diana\Desktop\python\RecScreen\RecScreen.py", line 3, in <module>
import cv2
File "C:\Users\Diana\AppData\Local\Programs\Python\Python310\lib\cv2\__init__.py", line 180, in <module>
bootstrap()
File "C:\Users\Diana\AppData\Local\Programs\Python\Python310\lib\cv2\__init__.py", line 75, in bootstrap
raise ImportError('ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.')
ImportError: ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation.
My code is:
# importing the required packages
import pyautogui
import cv2
import keyboard
import numpy as np
# Specify resolution
resolution = (1920, 1080)
# Specify video codec
codec = cv2.VideoWriter_fourcc(*"XVID")
# Specify name of Output file
filename = "Recording.avi"
# Specify frames rate. We can choose any
# value and experiment with it
fps = 60.0
# Creating a VideoWriter object
out = cv2.VideoWriter(filename, codec, fps, resolution)
cv2.namedWindow("Recording", cv2.WINDOW_NORMAL)
cv2.resizeWindow("Recording", 480, 270)
while True:
# Take screenshot using PyAutoGUI
img = pyautogui.screenshot()
# Convert the screenshot to a numpy array
frame = np.array(img)
# Convert it from BGR(Blue, Green, Red) to
# RGB(Red, Green, Blue)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
# Write it to the output file
#out.write(frame)
# Optional: Display the recording screen
cv2.imshow('Live', frame)
# Stop recording when we press 'ctrl+esc'
if keyboard.is_pressed("Ctrl+esc"):
break
# Release the Video writer
out.release()
# Destroy all windows
cv2.destroyAllWindows()
I can't figure out how to fix this error. Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误:递归: “ CV2”二进制扩展。检查OpenCV安装
它对我有用
作为管理员运行时,将其放在CMD中
ERROR: recursion is detected during loading of "cv2" binary extensions. Check OpenCV installation
it worked for me
put this in your cmd as you run as admin