Как правильно установить dlib под python?
Начну с предыстории. Сидел я значит над своим проектом и решил:»Вот бы крутую функцию добавить или типа того» и решил распознавание лиц сделать(давно хотел этим заняться, но никак руки не мог взяться).
И вот изучил так OpenCV и решил добраться до face_tecognition, который работает от dlib. Обычная установка через pip выводит ошибку. Прочитал как русские так и зарубежные решения(даже случайно на арабский сайт наткнулся =|), но ничего не нашел. Я только понял что надо установить cmake который у меня был установлен(как и отдельное ПО так и библиотека для python, оба добавлены в PATH) и Visual Studio с C++. Прошу пользователи хабр мне помочь.
Параметры ПО:Windows 10, python 3.9, для кодинга использую VS Code
- Вопрос задан более года назад
- 462 просмотра
How to install dlib library for Python in Windows 10
Hi! This is my first blog (or article depending on what you call) in English. Anyway, I am writing this blog because I have been facing with the trouble of this package for a while. I was trying to google it for the solution but I could not find the alternative one. So! this is my solution to install dlib library in Windows 10.
Some people might say that why don’t you just use conda install which is already complied. It is much easy to install. Well… I agree and I could do it. However, other packages, such as face_recognition could not leverage dlib when you used conda install . Hence, we need to use pip install .
Preparation
First thing first, there are two things required (really need it indeed!).
- CMake: This is because dlib was developed in C based programming language, so it needs this program to use it. It can be found in the link https://cmake.org/download/. To make sure matching with your operation system, in our case is Windows 10 64-bit version.
- Visual studio: As I mentioned before, dlib is C based programming language. Another thing that really need is compiler. The Visual studio can be downloaded in the link https://visualstudio.microsoft.com/visual-cpp-build-tools/. After finishing the installation, you need to install additional packages for C, C++ programming, which is Packages CMake tools for Windows
Note
Sometimes we need manage the Windows PATH environment for CMake. (If you already added during installation, you can skip this section).
For checking whether the PATH already added or not, you can go to Environment Variables on Windows by go to This PC > Properties > Advance system settings. Then, go to Tab Advanced and click on Environment Variables.
Another windows will pop-up and click Edit…
If you are unable to find CMake path, you should add the CMake installed directory like image below.
Install
Everything is looking good so far. Now we can install dlib into our python environment. First of all, you need to install CMake library.
pip install cmake
Then, you can install dlib library using pip install .
pip install dlib
After passing enter, you laptop or desktop will run the C, C++ Compiler. If you got something like image below, you would be fine.
After these all, you will get dilb installed on your Windows 10 by not using conda install compiler.
For further discussion or anyone would like to contact me. We could do it over the LinkdIn below.
How to Install dlib Library for python in windows 10
In this article, We are going to know how to install dlib library for Python in windows 10.
Dlib is one of the most powerful and easy-to-go open-source library consisting of machine learning library/algorithms and various tools for creating software. It was initially released in 2002. It has been used widely in many big industries, companies and for various big projects, etc. It also has many more types of algorithms that have a greater role in the real world.
Dlib is mostly used for face recognition purposes. They analyzed the object/face using the functions called HOG (Histogram of oriented gradients) and CNN (Convolutional Neural Networks). Face recognition nowadays are been used widely in many applications.
How to install dlib library.
First of all we have to set up the environment for the installation of dlib library. There are a few things that should be pre-installed before installing the dlib library. If these things aren’t properly installed or set up the dlib will not get installed properly. Let us see how we can do it.
Step 1: Install Python
Install Python on Windows. and after that to check whether Python is properly installed or not check the python version using the below command.
Python Installed Successfully
Step 2: Install CMake
Install CMake from its official website https://cmake.org/download/ and make sure choose the right version according to your system configuration.

While installing CMake select Add CMake to the system PATH to avoid any error in the next steps.

Step 3: Install visual studio.
Install the c++ compiler of the visual studio code community version. For that go to the visual studio code official website https://visualstudio.microsoft.com/visual-cpp-build-tools/ and download the visual studio code community version after that as you can see in the below image, select Desktop development with c++ while installing VS code.

Installing Desktop development with c++
Step 4: Install cmake module.
After you have installed visual studio [Desktop development with c++] successfully, now go to your command prompt and type “pip install cmake”

Step 5: Install dlib library.
After you have installed cmake module successfully, go ahead and install the dlib library as shown in below image.

Now, the dlib library is installed successfully and to verify the installation of dlib library open command prompt and type the command as shown in the below image.

Verify dlib installation.
In the above code, we are importing dlib library and it is successfully imported without giving any error on the other hand “import numpy” gives an error because NumPy is not installed on the system.
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out — check it out now!
Last Updated : 17 Jul, 2022

Like Article
pyperclip 1.8.2
Pyperclip is a cross-platform Python module for copy and paste clipboard functions. It works with Python 2 and 3.
Install on Windows: pip install pyperclip
Install on Linux/macOS: pip3 install pyperclip
Example Usage
>>> import pyperclip >>> pyperclip.copy('The text to be copied to the clipboard.') >>> pyperclip.paste() 'The text to be copied to the clipboard.'
Currently only handles plaintext.
On Windows, no additional modules are needed.
On Mac, this module makes use of the pbcopy and pbpaste commands, which should come with the os.
On Linux, this module makes use of the xclip or xsel commands, which should come with the os. Otherwise run “sudo apt-get install xclip” or “sudo apt-get install xsel” (Note: xsel does not always seem to work.)
Otherwise on Linux, you will need the gtk or PyQt4 modules installed.
