Dlib Installation on Windows 10

Not able to install dlib on Windows 10 and Python 3.7

I tried so many things to work with the latest version of Anaconda which is Python 3.7. However, I was unable to do so. Because none of the .whl file were compatible with Python 3.7, but with Python 3.6. So, I followed the link to downgrade the Python version to 3.6. This way spyder as well as Python would be downgraded to the 3.6 version. Once I had done so, I installed OpenCV using the below commands.

pip install opencv-python
pip install opencv-contrib-python

I installed dlib using the following command.

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

This successfully installed the latest version of dlib.

To check if everything got installed properly, the commands I used and the output I got on Anaconda prompt was as follows.

(py36) C:\Users\dbi227> python
Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 14:00:49) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.1.1'
>>> import dlib
>>> dlib.__version__
'19.8.1'

It is important to check if your iPython installation is also downgraded to 3.6 or not. For that, I got an option spyder(py36) apart from spyder(anaconda3) on my start option. Make sure you click on spyder(py36). Because that is the one where the libraries are installed. To check it, you can just type:

import cv2
import dlib

If these commands do not show any error, then the libraries are correctly installed.

Installation of dlib with pip fails on Windows 10

Here I got the error that line

CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

  • set CMake path into environment variable (As Shown in Figure)
    Sample Image

  • Installing Visual Studio build tool latest version
    link: https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2017
    Sample Image

  • after installing the Visual studio build tool select the package which needed and download it.
  • after download & installing successfully visual studio install dlib by commanding in CMD(ADMINISTRATOR) pip install dlib

DLIB library installation error through pip

As you are using Anaconda Navigator, the IDLE will be either Jupyter Notebook or Spyder. DLIB is a regular upgrading library for facial recognition. It cannot be installed on the base environment. @Avinash mentioned regarding two more libraries cmake and face_recognition the major issue for is DLIB.

Follow the below steps to install DLIB using Anaconda Navigator

  1. Open Anaconda Navigator or Open Anaconda Prompt

  2. Click on Environments (For anaconda navigator UI)

  3. Click on "Create" and to create a new environment (For anaconda navigator UI)

  4. Select the python version. (For anaconda navigator UI)

  5. Click on create. (For anaconda navigator UI)

  6. Open anaconda navigator

  7. Enter the following command to navigate from base environment to virtual environment just created

  8. Enter the following command to install DLIB

If you are using normal Python IDLE, use the following procedure.

  1. Virtual Environment creation using command prompt

Syntax: python3 -m venv [Virtual Environment Name]

Code: python3 -m venv dlib


  1. Activate Virtual Environment

Syntax: .\[Virtual Environment Folder Name]\Scripts\activate

Code: .\dlib\Scripts\activate

or you can directly mention as

activate dlib

  1. Finally you will be shifter from base environment to virtual environment

  2. Deactivating virtual environment

    deactivate

If you are not having proper UI access, then directly go to Anaconda Navigator and use the below command for virtual environment creation.

  1. Open Anaconda Prompt

  2. Check for conda installed in path

    conda -V

  3. Check if conda is updated or not

    conda update conda

  4. Create a virtual environment

syntax: conda create --name [Virtual Environment Name] python=[Version you want to install]

code: conda create --name dlib python=3.8

Installing DLIB in virtual environment.

pip install dlib

remaining activating and deactivating are same.



Related Topics



Leave a reply



Submit