error while install dlib on cmd, could not build wheels for dlib
Asked Answered
E

13

6

im getting this error while trying o install dlib on cmd i already install cmake version 3.26.1 visual studio n python version is 3.10

pip install dlib

and the results

Collecting dlib
  Using cached dlib-19.24.1.tar.gz (3.2 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
  ╰─> [14 lines of output]
      running bdist_wheel
      running build
      running build_py
      running build_ext
      Traceback (most recent call last):
        File "C:\Users\shiri\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
          return _run_code(code, main_globals, None,
        File "C:\Users\shiri\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
          exec(code, run_globals)
        File "C:\Users\shiri\AppData\Local\Programs\Python\Python310\Scripts\cmake.exe\__main__.py", line 4, in <module>
      ModuleNotFoundError: No module named 'cmake'

      ERROR: CMake must be installed to build dlib

      [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

i dont know what to do, please help:"

Electrical answered 19/4, 2023 at 7:43 Comment(6)
"CMake must be installed to build dlib" ... have you installed CMake? cmake.org/downloadSoftball
yes, n i dont know why it says i dontElectrical
Did you restart your shell to get it to pick up changes to your PATH environment variable?Softball
ModuleNotFoundError: No module named 'cmake' - Have you searched for that error message? E.g. that question suggests that you need to install Python module named "cmake".Silly
yes i already install cmakeElectrical
What do you mean by "install cmake"? Have you installed the program or the Python package (via pip)?Silly
P
8

First of all, you must install the c++ packages in visual studio, as it is here: https://medium.com/analytics-vidhya/how-to-install-dlib-library-for-python-in-windows-10-57348ba1117f

I had the same problems installing the face-recognition library and got it working after trying these versions of cmake and dlib:

pip install cmake==3.25.2
pip install dlib==19.24.2

in other versions dlib installation could not be completed. I'm using a virtual environment with Python 3.9.1 and Windows 11, Also in python global I do not have cmake or dlib installed, only in my virtual environment

Peavey answered 27/4 at 5:8 Comment(1)
Your answer has worked for me everytime.Burtonburty
I
2

ERROR: CMake must be installed to build dlib

You can do these commands in terminal:

pip install cmake 

Then reinstall dlib.

You said you have installed the cmake package, you can also check whether you have chosen the correct Python interpreter.

Insectarium answered 20/4, 2023 at 1:18 Comment(1)
i have alredy installed cmake Version: 3.26.3 and the eror when installing dlib is still goingJoo
L
1

You need to download the dlib-whl file. For example, if you're using python 3.11 then you will download dlib-whl file for this specific python version. After downloading just move into the directory where you saved the dlib-whl file and then run py -m pip install dlib-whl-file-name (Replace dlib-whl-file-name with actual filename).
You can also follow this video https://www.youtube.com/watch?v=9zeb902f98s

Lillian answered 9/10, 2023 at 8:14 Comment(0)
G
1

If you are using a Windows system, to install dlib, you need to have C++ installed.

"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++."

Goblet answered 21/10, 2023 at 20:32 Comment(0)
T
1

I was having trouble with this too, but I finally figured out a solution.

My setup is Windows 10 Home, PyCharm IDE, Python 3.11 (running in the .venv).

The way I was able to get this to work was:

  1. install CMake
  2. install VS Build Tools with Desktop Development C++
  3. download the Dlib .whl file for my Python version
  4. open the terminal within PyCharm
  5. change directories to where I saved the .whl file (in my case I saved it in my .venv/Lib/site-packages folder)
  6. run pip install [.whl filename (including extension)]

That finally got Dlib installed.

Telangiectasis answered 20/4 at 4:15 Comment(0)
S
0

Upgrade pip and setuptools: Before attempting to install dlib again, you can upgrade pip and setuptools to their latest versions using the following command:

pip install --upgrade pip setuptools

Retry installing dlib: Now, you can try installing dlib again using pip:

pip install dlib
Sessoms answered 10/7, 2023 at 22:29 Comment(0)
G
0

For those running on a linux this helped me. Install the build-essential package, which includes the gcc and g++ compilers and make, along with cmake.

yum install -y gcc-c++ make cmake

Godevil answered 21/9, 2023 at 23:13 Comment(0)
R
0

Running on Conda environment worked for me.

Recidivism answered 5/1 at 10:53 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Dilan
F
0

Let me say straightforward... if ur doing ai project like face recognition or something like that... dlib plays a crucial role. So, follow my steps to solve the error..

Step1 -- Install CMake. Download and install CMake from the official website. Or use pip install cmake.

Step2 -- Install Visual Studio Build Tools. dlib requires a C++ compiler, and on Windows, you can use the Visual Studio Build Tools. You can download and install them from the official website. During installation, make sure to select the "Desktop development with C++" workload.

Step3 -- Install Boost. dlib depends on the Boost C++ libraries. You can manually install Boost by following these steps:

Download the Boost library from the official website: Boost C++ Libraries. Extract the Boost archive to a location on your machine. Open a Command Prompt and navigate to the Boost directory. Run the following command to build Boost: bootstrap.bat then run: b2 Thats it....

now intall dlib (try pip3 instead of pip).

Felice answered 21/1 at 7:50 Comment(0)
T
0

I was trying to install face_recognition library and had the same issue. Looks like pip is not picking up the CMAKE path.

Instead, install the Dlib manually.

TRY THIS:

  1. make sure you have CMAKE installed by running cmd pip install cmake
  2. Go to dlib GitHub repo and download as a zip file
  3. Once downloaded (should prolly be named 'dlib-master', go into the folder, open a terminal window within the folder and run this cmd python3 setup.py install

This should do the trick. Just to make sure it is successfully installed. try running the cmd pip install dlib and you should get a response that the requirement is already satisfied.

Hope this helps. Cheers!

Ticktock answered 4/4 at 20:19 Comment(0)
W
0

The issue is that the cmake module might not be installed in your conda environment. Even though you have CMake installed globally on your system, the Python environment you're using might not have access to it. For me it worked out by the following way -

  1. activate your environment you are working in using 'conda activate env_name'

  2. Then install cmake in this conda env using this command -> conda install -c conda-forge cmake

This will help you solve your issue

Wimsatt answered 9/4 at 22:22 Comment(0)
V
0

Install it with anaconda: anaconda.org/conda-forge/dlib

conda install conda-forge::dlib
Vivianaviviane answered 8/5 at 9:43 Comment(0)
P
0

If you encounter issues installing the face_recognition library, try the following steps:

  • Download CMake from here and follow the installation instructions for your operating system.

  • Install face_recognition via pip:

pip install face_recognition

This method resolved my installation issues.

Pindaric answered 13/6 at 10:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.