You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mediapipe导入报错:ImportError: DLL load failed while importing _framework_bindings 求助

Mediapipe导入报错:ImportError: DLL load failed while importing _framework_bindings 求助

我在运行一个通过手势控制屏幕亮度的Python程序时,遇到了这个导入错误,试了好几种办法都没解决,想请大家帮忙看看!

我运行的程序代码:

# Importing Libraries 
import cv2 
import mediapipe as mp 
from math import hypot 
import screen_brightness_control as sbc 
import numpy as np 

# Initializing the Model 
mpHands = mp.solutions.hands 
hands = mpHands.Hands( 
    static_image_mode=False, 
    model_complexity=1, 
    min_detection_confidence=0.75, 
    min_tracking_confidence=0.75, 
    max_num_hands=2) 

Draw = mp.solutions.drawing_utils 

# Start capturing video from webcam 
cap = cv2.VideoCapture(0) 

while True: 
    # Read video frame by frame 
    _, frame = cap.read() 

    # Flip image 
    frame = cv2.flip(frame, 1) 

    # Convert BGR image to RGB image 
    frameRGB = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) 

    # Process the RGB image 
    Process = hands.process(frameRGB) 

    landmarkList = [] 
    # if hands are present in image(frame) 
    if Process.multi_hand_landmarks: 
        # detect handmarks 
        for handlm in Process.multi_hand_landmarks: 
            for _id, landmarks in enumerate(handlm.landmark): 
                # store height and width of image 
                height, width, color_channels = frame.shape 

                # calculate and append x, y coordinates 
                # of handmarks from image(frame) to lmList 
                x, y = int(landmarks.x*width), int(landmarks.y*height) 
                landmarkList.append([_id, x, y]) 

            # draw Landmarks 
            Draw.draw_landmarks(frame, handlm, 
                                mpHands.HAND_CONNECTIONS) 

    # If landmarks list is not empty 
    if landmarkList != []: 
        # store x,y coordinates of (tip of) thumb 
        x_1, y_1 = landmarkList[4][1], landmarkList[4][2] 

        # store x,y coordinates of (tip of) index finger 
        x_2, y_2 = landmarkList[8][1], landmarkList[8][2] 

        # draw circle on thumb and index finger tip 
        cv2.circle(frame, (x_1, y_1), 7, (0, 255, 0), cv2.FILLED) 
        cv2.circle(frame, (x_2, y_2), 7, (0, 255, 0), cv2.FILLED) 

        # draw line from tip of thumb to tip of index finger 
        cv2.line(frame, (x_1, y_1), (x_2, y_2), (0, 255, 0), 3) 

        # calculate square root of the sum of 
        # squares of the specified arguments. 
        L = hypot(x_2-x_1, y_2-y_1) 

        # 1-D linear interpolant to a function 
        # with given discrete data points 
        # (Hand range 15 - 220, Brightness 
        # range 0 - 100), evaluated at length. 
        b_level = np.interp(L, [15, 220], [0, 100]) 

        # set brightness 
        sbc.set_brightness(int(b_level)) 

    # Display Video and when 'q' is entered, destroy 
    # the window 
    cv2.imshow('Image', frame) 
    if cv2.waitKey(1) & 0xff == ord('q'): 
        break

遇到的错误:

ImportError: DLL load failed while importing _framework_bindings: A dynamic link library (DLL) initialization routine failed.

我已经尝试过的所有方法:

  • 检查Python版本:确认使用的是Python 3.7到3.10之间的兼容版本
  • 重新安装Mediapipe:
    • 先卸载:pip uninstall mediapipe
    • 再重新安装:pip install mediapipe
  • 检查依赖并升级:
    • 升级pip:pip install --upgrade pip
    • 重新安装Mediapipe:pip install mediapipe
  • 尝试安装特定版本的Mediapipe:pip install mediapipe==0.8.10(可替换成其他想要尝试的版本)
  • 检查缺失的DLL:确保Windows系统已更新,安装了最新的Visual C++ Redistributable
  • 以管理员身份运行终端或IDE
  • 创建虚拟环境并重新安装依赖:
    python -m venv myenv
    # Windows系统激活环境
    myenv\Scripts\activate
    # macOS/Linux系统激活环境
    source myenv/bin/activate
    # 安装所有需要的依赖
    pip install mediapipe opencv-python numpy screen-brightness-control pycaw
    
  • 关闭其他后台软件避免冲突,重新运行脚本

但尝试完这些之后,还是弹出相同的错误,有没有其他解决办法呀?

备注:内容来源于stack exchange,提问作者Akash S G

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.14 18:08:12