SoFunction
Updated on 2024-10-30

Win10 environment python3.7 install dlib module trips through the pits

Read an article in the headlines, said five lines of code to achieve face recognition, a moment of interest, to mess with the

First, I followed the article and took a few steps, but when I ran the code later, even though import dlib didn't report an error, the code ran as follows

The detector = dlib.get_frontal_face_detector() statement reports an error saying that the dlib module could not find the get_frontal_face_detector property (of course willingly it's possible that I overlooked a couple of error messages in the course of following the article)

Later also found a lot of articles on the Internet, information to learn, either the information is not careful enough to speak also not comprehensive enough, resulting in the problem has not been resolved, and then cross-centered to start again, do not let go of any of the wrong information, and then figured out what I think is the correct operating position. Not much to say, immediately on the dry goods ~

1, install VS2017, full name visualStudio2017, I downloaded the Community Edition (free)

download address/zh-hans/downloads/ 

2, download vs2017 after the installation notes, there are many modules, I initially installed only python environment results are not right, at least to select the . net desktop C + + + development environment

ps: when installing the module pay attention to choose a good location, I am the beginning of the default location for the C disk, the back of the upgrade to install other modules when the path can not be changed, if the remaining space of the disk drive is not enough on the tragedy!

After installing the C++ development environment in vs2017, you should add the path to the environment variable, and see the following screenshot to show that cl is configured properly

Just in case, I've added these four prefixes to the environment variable.

3. python3.7 installation (omitted)

4. Use pip install cmake to install the cmake plugin.

Or directly online/download/ downloading cmake-3.13. Direct Installation I've done both of these anyway, then configure the cmake bin path to the environment variable

Then type cmake into cmd and you will see the following display indicating that cmake was installed successfully

5. Then go to /downloadboost

Then unzip the downloaded boost and run the file (if the configuration is OK) to generate, andThere are people on the Internet who say, "How can I change this?(This file, the more I try to modify the more chaotic, decided not to modify this file)

Then run b2 install from the command line in the current directory (this process takes a long time to complete, be patient ~ it takes about 2 hours)

And then after a long wait, the execution b2 -a --with-python address-model=64 toolset=msvc runtime-link=static (Note that with is preceded by two dashes)

6. Add the path to the environment variable of the boost file after the installation has been completed.

7, download dlib source code /files/, I downloaded two versions of dlib-19.16 (the installation failed) and dlib-19.14

cd to the dlib directory and run the command python install Waiting for the installation to complete, I don't know why my installation of dlib-19.16 failed, dlib-19.14 succeeded, the success screenshot is as follows

Then copy the three folders in the installed directory, as shown in the following screenshot, to the python installation folder under the lib folder

Then, you can remove the file shown in the screenshot from the dlib installation path.

Copy to the following location in the python installation directory

At this point, the installation has been completely finished, in order to check whether it is normal or not, you can quickly verify as shown in the screenshot.

If you don't get an error, it means you're fine. Then you can try it with dlib's example in pycharm, and the result will be as follows:

summarize

The above is a small introduction to the Win10 environment python3.7 installation of dlib module trips over the pit, I hope to help you, if you have any questions please leave me a message, I will reply to you in a timely manner. I would also like to thank you very much for your support of my website!
If you find this article helpful, please feel free to reprint it, and please note the source, thank you!