How to install dlib in Python 3 in less than 5 mins - a step-by-step process #python

preview_player
Показать описание
By watching this video, you will learn how to install DLIB library in Python 3 in less than 5 mins on MacOS.

This video will teach how to create a python project folder first then a python virtual environment within it, activate the python virtual environment, and then pip install the dlib library within it.

dlib is a toolkit for making real-world machine learning and data analysis applications.
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.
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)

[For Windows users]
(create virtual environment)
virtualenv myenv

(activate virtual environment)
myenv\Scripts\activate

We will first check if we were able to successfully install dlib using the pip list command by running it in the virtual environment.

Finally, we will programmatically test the successful installation of the dlib library in the python project by printing its version.

You can extrapolate these techniques to install other packages in your python project by creating a virtual environment too.

Make sure that before you instal dlib library you have cmake installed and it would be better to have wheels installed as well.

If you don't have the latest python installed on your Mac then you can watch this video -

How to install Pycharm on MacOS Catalina or Big Sur

If you haven't subscribed on my channel yet then do hit the subscribe button as well as the bell icon as that way you won't miss out on these instructional videos I create for you.

Also watch,
How to install flask on MacOS

How to install pip on macOS

How to install Pycharm on MacOS Catalina or Big Sur

Watch more videos from Joey'sTech on dynamic programming
Arithmetic Slices

Is Subsequence

Best Time to buy and sell stock

Stone Game

Make sure you subscribe to my channel Joey'sTech so that you don't miss out on any instructional videos I make.
Рекомендации по теме
Комментарии
Автор

It was super helpful brother.

Thanks for the tutorial

karimkhanpathan-mi
Автор

for those all that process did not work just install python 3.8.10 and run the usual command for the dlib installation, it will work like a charm

sologrinder
Автор

hi Joey
I’m trying to install dlib for two days and after following your instructions still I’m getting the same error
error: subprocess-exited-with-error

first ERROR: Failed building wheel for dlib

then it show that dlib unsuccessfully installation
note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> dlib

can you help me on this please!

akhillasalmufargi
Автор

Hey, thanks for the video. But it didn't work for me, I have already spent more than 3 days on this issue.

Getting this error when trying to import dlib :
ImportError: dlopen(/Users/<<USERNAME>>/Projects/imageSegregator/venv/lib/python3.8/site-packages/_dlib_pybind11.cpython-38-darwin.so, 0x0002): symbol not found in flat namespace '_DGifCloseFile'

Tried almost every available method on internet, also tried installing dlib through git repo -> setup.py method.

My macOs version is 13.4.1 and M1 chip,
Python version is 3.8.

Any help would be highly appreciated

AmanPanjwani
Автор

Thanks for this tutorial. You helped me a lot

marilsonporfirio
Автор

After creating python virtual environment, still getting error during 'dlib' installation …

Device - macOS Sonoma Version 14.1.1
(M1)

Python Version - 3.10.0

Error -
“ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib which use PEP 517 and cannot be installed directly”

Can u please help me to fix this issue !!!! …

aritdutta
Автор

getting this error while installing dlib :
Using cached dlib-19.24.2.tar.gz (11.8 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: dlib
Building wheel for dlib (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for dlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [81 lines of output]
<string>:208: SyntaxWarning: invalid escape sequence '\('
<string>:209: SyntaxWarning: invalid escape sequence '\('
<string>:210: SyntaxWarning: invalid escape sequence '\('
running bdist_wheel
running build
running build_ext
<string>:125: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
Building extension for Python 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
Invoking CMake setup: 'cmake -A x64'
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:5 (message):






You must use Visual Studio to build a python extension on windows. If you
are getting this error it means you have not installed Visual C++. Note
that there are many flavors of Visual Studio, like Visual Studio for C#
development. You need to install Visual Studio for C++.







-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
File "C:\Users\ankit\Desktop\dlib_install\dlib_venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "C:\Users\ankit\Desktop\dlib_install\dlib_venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])

File "C:\Users\ankit\Desktop\dlib_install\dlib_venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 251, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,

File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\build_meta.py", line 404, in build_wheel
return self._build_with_temp_dir(

File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\build_meta.py", line 389, in _build_with_temp_dir
self.run_setup()
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 218, in <module>
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\__init__.py", line 103, in setup
return

File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
return run_commands(dist)

File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
dist.run_commands()
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
self.run_command(cmd)
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
super().run_command(command)
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
cmd_obj.run()
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 368, in run
self.run_command("build")
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command

File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
super().run_command(command)
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
cmd_obj.run()
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run
self.run_command(cmd_name)
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command

File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
super().run_command(command)
File "C:\Users\ankit\AppData\Local\Temp\pip-build-env-oyeuajik\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
cmd_obj.run()
File "<string>", line 130, in run
File "<string>", line 167, in build_extension
File "C:\Program Files\Python312\Lib\subprocess.py", line 413, in check_call
raise CalledProcessError(retcode, cmd)
Command '['cmake', 'C:\\Users\\ankit\\AppData\\Local\\Temp\\pip-install-rocjkqgf\\dlib_b38c9999019b4630beed1b6e779f0349\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\ankit\\AppData\\Local\\Temp\\pip-install-rocjkqgf\\dlib_b38c9999019b4630beed1b6e779f0349\\build\\lib.win-amd64-cpython-312', '-DPYTHON_EXECUTABLE=C:\\Users\\ankit\\Desktop\\dlib_install\\dlib_venv\\Scripts\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\ankit\\AppData\\Local\\Temp\\pip-install-rocjkqgf\\dlib_b38c9999019b4630beed1b6e779f0349\\build\\lib.win-amd64-cpython-312', '-A', 'x64']' returned non-zero exit status 1.
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for dlib
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects

[notice] A new release of pip is available: 23.2.1 -> 23.3.2
[notice] To update, run: python.exe -m pip install --upgrade pip

(dlib_venv)

ankitsinghdhanai