Python solves the installation failure of dilb and face_recognition third-party packages

Table of contents

The third-party package installation of dilb and face_recognition failed

Pro-test effective solution: whl installation method


The third-party package installation of dilb and face_recognition failed

Scenario recurrence: Because dlib+face_recognition is needed to do some face recognition projects based on OpenCV, when downloading and installing pip Tsinghua source in Pycharm, the error shown in the figure below appears and the installation fails.

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple dlib   

Error: Unable to install face detection dlib library.

Reason : It is easy to make mistakes when python installs the face recognition library face_recognition , and needs to rely on the dlib library, but generally everyone will make an error when pip install dlib, because the version of the dlib library does not match the version of python .

The dlib library is a Python library for facial key point detection, but because it is written in C++ (or does it require C++ compilation?), it may encounter various problems during installation.

 

Pro-test effective solution: whl installation method

Note that only specific versions are supported, please check whether the versions supported by pip are consistent

(1) Check the Python version in your computer, and then download the .whl file of the corresponding dlib library and place it in the directory you want to install or the virtual environment package directory.

The corresponding version of the whl file link is as follows:
Python3.6 corresponds to the .whl file link: dlib-19.6.0-cp36-cp36m-win_amd64.whl
Python3.7 corresponds to the .whl file link: dlib-19.17.99-cp37-cp37m-win_amd64 .whl
Python3.9 corresponds to the .whl file link: dlib-19.22.99-cp39-cp39-win_amd64
After the download is complete, you can install the .whl file directly in Pycharm.

Here, my Python version is 3.9, so I should find the dlib version corresponding to Python3.9.X, so click the link to download the .whl file corresponding to Python3.9.

(2) After the compressed package is decompressed, you can see the whl file,

First modify the name of the whl file, remove the following (2), and change it to pip install dlib-19.22.99-cp39-cp39-win_amd64.whl,

(3) Enter pycharm to open the terminal terminal, first enter the file path where the whl file is located, and then enter the command,

pip install dlib-19.22.99-cp39-cp39-win_amd64.whl

As can be seen from the figure, the dilb library has been installed successfully.

(4) After the dlib library has been installed successfully, let's try to install the face_recognition library again, and run the following command in the terminal,

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple face_recognition

can be seen,

The face_recognition third-party package was also installed successfully.

ok, done.

Guess you like

Origin blog.csdn.net/qq_45956730/article/details/128993857