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 :
16 Answers 16
Install Dlib from .whl
Dlib 19.7.0
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
- Download the CMake installer and install it: https://cmake.org/download/
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.
Restart The Cmd or PowerShell window for changes to take effect.
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
Run the installation: python setup.py install
Linux Dlib 19.17.0
note: To install Dlib for Python 2.x use python instead of python3 you can check your python version via python -V
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
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
You have to install cmake as the error tells you.
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.
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
for above method .whl file shoud be in the working directory
Below link for python3.6 supporting dlib link, for python 3.5 u can replace with dlib 35.whl link
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.
Note you can find few other dlib packages, but the above one will works perfectly with this procedure.
dlib will be successfully installed.
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).
Install Dlib on Windows
In this post, we will provide step by step instructions on how to install Dlib on Windows.
Compiling Python modules such as NumPy, SciPy etc. is a tedious task. Anaconda is a great Python distribution which comes with a lot of pre-compiled Python packages. So we will use Anaconda as our Python distribution.
An alternative to Anaconda is that you install official Python library and use Christoph Gohlke’s awesome repository to install pre-compiled Python modules.
This tutorial is based on using Anaconda so we may not be able to help if you choose to use Gohlke’s precompiled binaries or if you compile Python libraries from source.
If you intend to use Dlib only in C++ projects, you can skip Python installation part.
Now let’s go through the steps to install Dlib. Follow our previous post Install OpenCV3 on Windows to complete Step 1, 2 and 3.
Step 1: Install Visual Studio 2015
Step 2: Install CMake v3.8.2
Step 3: Install Anaconda 3
Step 4: Download Dlib
Step 5: Build Dlib library
Extract this compressed file. Open Windows PowerShell or Command Prompt and move to the directory where you have extracted this file.
If you are running these commands on Command Prompt replace ` (backtick) with ^ (caret).
Dlib will be installed within dlib-19.6\build\install directory. We will use CMake to build Dlib examples but you can use Visual Studio too. This directory (dlib-19.6\build\install) contains include and library folders which you can specify in Visual Studio to build projects using Dlib.
Step 6: Update user environment variable – dlib_DIR
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.
- Press Windows Super key, search for “environment variables”.
- Click Environment Variables in System Properties window.
- Click New in “User Variables” (in upper half of window).
- Under variable name write dlib_DIR and under variable value write full path to directory dlib-19.6\build\install\lib\cmake\dlib
On my machine path is: D:\programming\dlib-19.6\build\install\lib\cmake\dlib
This directory contains file “dlibConfig.cmake”. This is used by CMake to configure dlib_LIBS and dlib_INCLUDE_DIRS variables to generate project files. Before assigning the value to variable dlib_DIR make sure that this path has file dlibConfig.cmake. - Now click ok to save and close environment variables window.
Note: If you have an open Command Prompt/Power Shell window before these values were updated, you have to close and open a new Command Prompt/Power Shell window again.
Step 7: Build Dlib examples
We will use our CMakeLists.txt file instead of one which is shipped with Dlib.
Download modified CMakeLists.txt file and put it in dlib-19.6\examples directory and replace the default one with this one. Then follow the steps given below:
Once build is complete, it will generate executables for all examples in examples\build\Release folder.
Step 8: Test Dlib’s C++ example
We will test Face Landmark Detection demo to check whether we have installed Dlib correctly.
Download trained model of facial landmarks from Dlib’s website. Extract this file (shape_predictor_68_face_landmarks.dat.bz2) to Dlib’s root directory (dlib-19.6).
Step 9: Install Dlib’s Python module (Only Anaconda 3)
Compiling Python bindings for Dlib from source is non-trivial. You have to compile Boost.Python from scratch and configure some environment variables (such as BOOST_ROOT and BOOST_LIBRARYDIR) before you can compile Python module of Dlib. We are skipping that part for now. A complete tutorial on how to build Dlib Python bindings from source will be released in future.
To save time and efforts it is suggested to use Anaconda 3. You can install a compiled binary of dlib v19.4 from Anaconda. At the time this article was updated Dlib’s latest available version on Anaconda’s conda-forge repository is 19.4. So we will install v19.4 instead of 19.6
Step 10: Test Dlib’s Python example
Subscribe & Download Code
If you liked this article and would like to download code (C++ and Python) and example images used in all posts in this blog, please subscribe to our newsletter. You will also receive a free Computer Vision Resource Guide. In our newsletter, we share OpenCV tutorials and examples written in C++/Python, and Computer Vision and Machine Learning algorithms and news.
About
I am an entrepreneur with a love for Computer Vision and Machine Learning with a dozen years of experience (and a Ph.D.) in the field.
In 2007, right after finishing my Ph.D., I co-founded TAAZ Inc. with my advisor Dr. David Kriegman and Kevin Barnes. The scalability, and robustness of our computer vision and machine learning algorithms have been put to rigorous test by more than 100M users who have tried our products. Read More…
ENROLL IN OFFICIAL OPENCV COURSES
Установка dlib в Windows 10
Я хочу использовать dlib с Python для распознавания изображений. У меня есть приложение python, отлично работающее с OpenCV в Windows 10, но когда я хочу установить dlib из cmd , оно выдает мне следующую ошибку:
Установите Dlib из .whl
Dlib 19.7.0
Вы можете проверить его, загрузив пример с сайта, например SVM_Binary_Classifier.py и запустив его на своем компьютере.
Примечание: если это сообщение появляется, вы должны собрать dlib из источника:
dlib-19.7.0-cp36-cp36m-win_amd64.whl не поддерживается колесом на этой платформе
Установите Dlib из исходного кода (если вышеуказанное решение не работает)
Windows Dlib > 19.7.0
- Загрузите установщик CMake и установите его: https://cmake.org/download/
Добавьте путь к исполняемому файлу CMake в переменные среды:
set PATH=»%PATH%;C:\Program Files\CMake\bin»
примечание: путь к исполняемому файлу может отличаться от C:\Program Files\CMake\bin , просто установите соответствующую переменную PATH.
Примечание. Путь будет установлен временно, чтобы сделать изменение постоянным, его необходимо установить на вкладке «Дополнительные параметры системы» → «Переменные среды».
Перезапустите окно Cmd или PowerShell, чтобы изменения вступили в силу.
Проверьте версию Python: python -V . Это мой вывод: Python 3.7.2 , поэтому я устанавливаю его для Python3.x, а не для Python2.x
примечание: вы можете установить его как для Python 2, так и для Python 3, если вы установили разные переменные для разных двоичных файлов, например: python2 -V , python3 -V
Запустите установку: python setup.py install
Linux Dlib 19.17.0
Примечание: чтобы установить Dlib для Python 2.x, используйте python вместо python3 , вы можете проверить версию Python через python -V
- pip install cmake
- Установите инструменты сборки Visual Studio отсюда.
- В Visual Studio 2017 перейдите на вкладку Отдельные компоненты, Инструменты Visual C++ для Cmake и установите флажок в разделе «Компиляторы, инструменты сборки и среды выполнения».
- pip install dlib
Вам нужно установить Cmake.
dlib — это c++ libary с привязками python. Сначала его нужно построить. Я предполагаю, что это произойдет автоматически, как только вы установили Cmake
Вы должны установить cmake, как сообщила вам ошибка.
или непосредственно установить cmake отсюда https://cmake.org/download/
Как только CMake установлен, установите pLL dlib.
У меня были встроенные инструменты vstudio, и я сделал свой тест.
Выберите dlib.whl файл в соответствии с установленной версией python. Например, если установлена версия python 3.6.7, 64-битная система или если python равен 3.5.0 32 бит, выберите dlib-19.5. 1- cp36 -cp36m-win_ amd64.whl и dlib-18.17. 100- cp35 -none — win32.whl соответственно.
Полужирный текст говорит о поддерживаемой версией python.
Загрузите здесь файл с колесом или скопируйте адрес ссылки
для вышеописанного метода.whl файл должен находиться в рабочем каталоге
Ниже ссылка для python3.6, поддерживающая ссылку dlib, для python 3.5 u можно заменить ссылкой dlib 35.whl
Просто быстрая информация о том, что сработало для меня (два года спустя). Дэвис Кинг предоставил мне два способа добавления последней версии python dlib (19.17.0) в любую среду python в Windows 10. Обратите внимание, что я запускаю несколько конфигураций Linux в Oracle VirtualBox, но Windows 10 — это моя родная ОС, которая имеет доступ к графическому процессору Nvidia, поэтому мне нужно установить ее на Windows 10. (Невозможно получить доступ к графическому процессору — легко — через VirtualBox).
Первый — самый простой:
И тогда его можно легко построить из источников. Загрузите с https://pypi.org/simple/dlib/ и следуйте инструкциям на http://dlib.net/compile.html.
Также только что нашли другой способ доступа с помощью Visual Studio 2019 (или 2017). Используйте vcpkg — см. Ссылку https://vcpkg.readthedocs.io/en/latest/
Я собрал dlib 19.17 на Windows 10 с CMake, и он работал нормально, но потом я нашел vcpkg, и теперь библиотеки dlib являются неотъемлемой частью Visual Studio. Мне больше не нужно добавлять все внешние ссылки на C++ и компоновщик. Версия в vcpkg в настоящее время 19.16-1, и она построена с полной поддержкой CUDA.