我能够在Windows 10的Pycharm中成功安装Dlib,但在我的Python项目(人脸识别考勤系统)中“导入dlib”时出错。
环境: Windows 10,Python 3.10.10,dlib 19.23.1
代码:
import cv2
import numpy as np
import face_recognition
import os
from datetime import datetime
path = 'ImageBasic'
images = []
className = []
myList = os.listdir(path)
for cl in myList:
curImg = cv2.imread(f'{path}/{cl}')
images.append(curImg)
className.append(os.path.splitext(cl)[0])
print(className)
在 Pycharm 中运行代码时,我得到这个:
Traceback (most recent call last):
File "C:\Users\omkar\PycharmProjects\pythonProject\test.py", line 3, in <module>
import face_recognition
File "C:\Users\omkar\PycharmProjects\pythonProject\venv\lib\site-packages\face_recognition\__init__.py", line 7, in <module>
from .api import load_image_file, face_locations, batch_face_locations, face_landmarks, face_encodings, compare_faces, face_distance
File "C:\Users\omkar\PycharmProjects\pythonProject\venv\lib\site-packages\face_recognition\api.py", line 4, in <module>
import dlib
File "C:\Users\omkar\PycharmProjects\pythonProject\venv\lib\site-packages\dlib\__init__.py", line 19, in <module>
from _dlib_pybind11 import *
ImportError: DLL load failed while importing _dlib_pybind11: The specified module could not be found.
并在 pythonIDLE 中导入 DLIB:
import dlib
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import dlib
File "C:\Users\omkar\AppData\Local\Programs\Python\Python310\lib\site-packages\dlib\__init__.py", line 19, in <module>
from _dlib_pybind11 import *
ImportError: DLL load failed while importing _dlib_pybind11: The specified module could not be found.