dlib installation on Windows 10

PythonImage ProcessingDlib

Python Problem Overview


I want to use dlib with python for image recognition. I have the python app running great with OpenCV on Windows 10, but when I want to install dlib from the cmd it gives me this following error :

error: Cannot find cmake, ensure it is installed and in the path. You
can install cmake using the instructions at https://cmake.org/install/
You can also specify its path with --cmake parameter.

What should I do?

My command prompt error

Python Solutions


Solution 1 - Python

Install Dlib from .whl

Dlib 19.7.0

pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f

You can test it, downloading an example from the site, for example SVM_Binary_Classifier.py and running it on your machine.

Note: if this message occurs you have to build dlib from source:

> dlib-19.7.0-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform


Install Dlib from source (If the solution above doesn't work)##

Windows Dlib > 19.7.0

  1. Download the CMake installer and install it: https://cmake.org/download/

  2. Add CMake executable path to the Enviroment Variables:

    set PATH="%PATH%;C:\Program Files\CMake\bin"

    note: The path of the executable could be different from C:\Program Files\CMake\bin, just set the PATH accordingly.

    note: The path will be set temporarily, to make the change permanent you have to set it in the “Advanced system settings” → “Environment Variables” tab.

  3. Restart The Cmd or PowerShell window for changes to take effect.

  4. Download the Dlib source(.tar.gz) from the Python Package Index : https://pypi.org/project/dlib/#files extract it and enter into the folder.

  5. Check the Python version: python -V. This is my output: Python 3.7.2 so I'm installing it for Python3.x and not for Python2.x

note: You can install it for both Python 2 and Python 3, if you have set different variables for different binaries i.e: python2 -V, python3 -V

NOTE: Make sure to open the PowerShell as admin, and you're inside the dlib directory before proceeding to step 6


  1. Run the installation: python setup.py install

Linux Dlib 19.17.0

sudo apt-get install cmake

wget https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz

tar -xvzf dlib-19.17.0.tar.gz

cd dlib-19.17.0/

sudo python3 setup.py install

note: To install Dlib for Python 2.x use python instead of python3 you can check your python version via python -V

Solution 2 - Python

Follow these steps:

  • pip install cmake
  • Install Visual Studio build tools from here.
  • In Visual Studio 2017 go to the Individual Components tab, Visual C++ Tools for Cmake, and check the checkbox under the "Compilers, build tools and runtimes" section.
  • pip install dlib

Solution 3 - Python

Effective till now(2020).

pip install cmake
conda install -c conda-forge dlib

Solution 4 - Python

If you are using Anaconda Prompt (recommended),

conda install -c conda-forge dlib

Or you can use the approach mentioned below:

After spending a lot of time, this comment gave me the right result. https://github.com/ageitgey/face_recognition/issues/802#issuecomment-544232494

  1. Download Python 3.6.8 and install, make sure you add it to PATH.

  2. Install NumPy, scipy, matplotlib and pandas in your pc/laptop with this command in command prompt:-

    pip install numpy

    pip install scipy

    pip install matplotlib

    pip install pandas

  3. Go to https://pypi.org/project/wheel/#files and right-click on filename wheel-0.33.6-py2.py3-none-any.whl (21.6 kB) and copy link address. Then go to your pc/laptop, open command prompt and write this command "python -m pip install" after this command space first then paste the link copied. After installing successful go to the next step.

  4. Then go to this link, https://pypi.org/simple/dlib/ and right-click on filename "dlib-19.8.1-cp36-cp36m-win_amd64.whl" then copy link address. Then open command prompt and do the same as step 2 which is, write this command "python -m pip install" after this command space first then paste the link copied. then the dlib will be installed successfully.

  5. After that, type python and enter, then type import dlib to check dlib is installed perfectly. you can proceed to install face recognition.py which suite for python 3.6.

This is how it will be after dlib and face recognition installed.

Solution 5 - Python

You need to install Cmake.

dlib is an c++ libary with python bindings. It needs to be builded first. My guess is this will happen automatically once you have installed Cmake

Solution 6 - Python

As you can see many answers above, But i would like to post a quick solution which works for sure in Anaconda3. I haven't chosen Visual Studio as it consumes lot of memory.

Please follow the below steps.

Step 1:
Install windows cmake.msi and configure environment variable
Step 2:
Create a conda environment, and install cmake using the below command.
pip install cmake
Step 3:
conda install -c conda-forge dlib

Note you can find few other dlib packages, but the above one will works perfectly with this procedure.

dlib will be successfully installed.

Solution 7 - Python

So basically I have been searching the solution for two days. I tried everything

  • Installing Cmake
  • Adding path
  • installing dlib from the links mentioned in the answers
  • Installing ## Heading ## numpy, scipy, matplotlib, pandas
  • etc etc etc

BUT THE ONLY SOLUTION THAT WORKED WAS INSTALLING MICROSOFT VISUAL STUDIO C++

After installing MS VS C++ I ran command pip install dlib and it is working like a charm. BEST OF LUCK

Link to download Visual Studio C++

https://visualstudio.microsoft.com/thank-you-for-downloading-visual-studio-for-cplusplus/?sku=Community&rel=16&rid=30005

Solution 8 - Python

You have to install cmake as the error tells you.

you can follow this instructions https://www.learnopencv.com/install-dlib-on-windows/

or directly install cmake from here https://cmake.org/download/

Once cmake is installed pip install dlib should work.

I had vstudio building tools installed whe I did my test.

Solution 9 - Python

Choose dlib .whl file according to your installed python version. For example if installed python version is 3.6.7 , 64bit system or if python is 3.5.0 32 bit then choose dlib-19.5.1-cp36-cp36m-win_amd64.whl and dlib-18.17.100-cp35-none-win32.whl respectively.

Bolded text says the python supporting version.

Download wheel file from here or copy the link address

pip install dlib-19.5.1-cp36-cp36m-win_amd64.whl

for above method .whl file shoud be in the working directory

or

Below link for python3.6 supporting dlib link, for python 3.5 u can replace with dlib 35.whl link

pip install https://files.pythonhosted.org/packages/24/ea/81e4fc5b978277899b1c1a63ff358f1f645f9369e59d9b5d9cc1d57c007c/dlib-19.5.1-cp36-cp36m-win_amd64.whl#sha256=7739535b76eb40cbcf49ba98d894894d06ee0b6e8f18a25fef2ab302fd5401c7

Solution 10 - Python

1.use python 3.6.9 version

2.first install cmake.

conda install -c anaconda cmake

3. use these command to install dlib

pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f

Solution 11 - Python

Just a quick update on what has worked for me (two years later). Davis King has provided two ways to add the latest python dlib (19.17.0) to any python environment in Windows 10 for me. Note, I run several Linux configs in Oracle VirtualBox but Windows 10 is my native OS which has access to the Nvidia GPU so i need an install on Windows 10. (Cannot access the GPU - easily - through VirtualBox).

First - the easiest:

pip install dlib

and the website link: https://pypi.org/project/dlib/

And then it can be easily be build from sources. Download from https://pypi.org/simple/dlib/ and follow instructions on http://dlib.net/compile.html.

Also, just found another way to access with Visual Studio 2019 (or 2017). Use vcpkg - see link https://vcpkg.readthedocs.io/en/latest/

I built dlib 19.17 on Windows 10 with CMake and it worked fine but then I found vcpkg and now the dlib libraries are integral to the Visual Studio. I no longer need to add all the external links to C++ and the linker.The version in vcpkg is currently 19.16-1 and it is built with full CUDA support.

Hope this helps others..

Solution 12 - Python

You can use vcpkg to install dlib.

If you don't have vcpkg, you can get it here (Read Quick Start)

After you got vcpkg, run:

vcpkg install dlib:x64-windows

Solution 13 - Python

I have recently installed dlib on python 3.7. First I have installed cmake from anaconda navigator (cmake version 3.14.0) Next i installed visual studio 2019 and installed Desktop development with C++ . Then I do pip install dlib and now its working

Solution 14 - Python

None of the answers worked for me. This is what worked Assuming you have anaconda python 3.7 installed

  1. Dowload and install cmake(make sure to check the option to add cmake to system path during installation to avoid manually doing later) Download from this link cmake download

  2. conda install -c conda-forge dlib

Solution 15 - Python

It is basically a two-step process:

  1. install cmap
pip install cmap
  1. install dlib
pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f

Solution 16 - Python

If you're trying to install dlib on Windows 10 with Visual Studio 2019, then first perform:

pip install cmake

And set it in the environment variable. After that, make sure that you have the latest version of Visual Studio SDK installed. After that, perform:

pip install dlib

I hope this solves the problem

Solution 17 - Python

Simple and 100% working trick

(Make sure you install cmake)

My Anaconda python ver : 3.6.8 (64 bit) | OS :Windows 10

python -m pip install https://files.pythonhosted.org/packages/0e/ce/f8a3cff33ac03a8219768f0694c5d703c8e037e6aba2e865f9bae22ed63c/dlib-19.8.1-cp36-cp36m-win_amd64.whl#sha256=794994fa2c54e7776659fddb148363a5556468a6d5d46be8dad311722d54bfcf

enter image description here

Solution 18 - Python

Install dlib in Windows

download dlib from https://github.com/davisking/dlib.git

download camke from https://cmake.org/download/

Extract cmake and configure it as Environment variable to the extracted path my it was C:\Users\admin\Downloads\cmake-3.8.1-win32-x86\cmake-3.8.1-win32-x86\bin

Now extract dlib zip file and go to dlib folder

Follow this commands

cd dlib/test
mkdir build
cd build
cmake ..
cmake --build . --config Release

Now go to Release folder which would be at dlib\test\build\Release and execute this command dtest.exe --runall

This process takes time as cmake compiles all C++ files so stay clam. Enjoy!!!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDrillView Question on Stackoverflow
Solution 1 - PythonMarco D.G.View Answer on Stackoverflow
Solution 2 - PythonRajat BhattView Answer on Stackoverflow
Solution 3 - PythonSUMIT YADAVView Answer on Stackoverflow
Solution 4 - PythonAbhishek NView Answer on Stackoverflow
Solution 5 - PythonTruckerCatView Answer on Stackoverflow
Solution 6 - PythonsujithramanathanView Answer on Stackoverflow
Solution 7 - PythonBilal NasirView Answer on Stackoverflow
Solution 8 - PythonDedaloView Answer on Stackoverflow
Solution 9 - PythonRamisha Rani KView Answer on Stackoverflow
Solution 10 - PythonAkash DesaiView Answer on Stackoverflow
Solution 11 - PythonbarnwaldoView Answer on Stackoverflow
Solution 12 - PythonSymyonView Answer on Stackoverflow
Solution 13 - PythonTalha AnwarView Answer on Stackoverflow
Solution 14 - PythonChandan PurohitView Answer on Stackoverflow
Solution 15 - PythonGeekquadView Answer on Stackoverflow
Solution 16 - PythonBelide AakashView Answer on Stackoverflow
Solution 17 - PythonVinay ChaudhariView Answer on Stackoverflow
Solution 18 - PythonRohit SalunkeView Answer on Stackoverflow