Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dlib installation on Windows 10

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

like image 435
Drill Avatar asked Jan 28 '17 16:01

Drill


People also ask

How to install Dlib on Windows 10 with Visual Studio 2019?

If you're trying to install dlib on Windows 10 with Visual Studio 2019, then first perform: 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:

How to install Dlib library on Windows 10 without conda install compiler?

Then, you can install dlib library using pip install. After passing enter, you laptop or desktop will run the C, C++ Compiler. If you got something like image below, you would be fine. boom! you got this! After these all, you will get dilb installed on your Windows 10 by not using conda install compiler.

How to find out where dLib is installed?

This environment variable is needed for CMake to find out where Dlib is installed. CMake looks for a file named dlibConfig.cmake within directory dlib_DIR to find Dlib’s include and library directories.

How to install Dlib library in C++ using pip?

First of all, you need to install CMake library. Then, you can install dlib library using pip install. After passing enter, you laptop or desktop will run the C, C++ Compiler. If you got something like image below, you would be fine.


2 Answers

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

like image 87
Marco D.G. Avatar answered Sep 29 '22 19:09

Marco D.G.


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
like image 45
Rajat Bhatt Avatar answered Sep 29 '22 21:09

Rajat Bhatt