davisking / dlib

A toolkit for making real world machine learning and data analysis applications in C++
http://dlib.net
Boost Software License 1.0
13.2k stars 3.34k forks source link

[Bug]: cmake not found during dlib installation using pip (even though cmake installed correctly) #2961

Open atharva-p opened 1 month ago

atharva-p commented 1 month ago

What Operating System(s) are you seeing this problem on?

Windows

dlib version

19.24.4

Python version

3.12.1

Compiler

gcc

Expected Behavior

using pip in a virtual environment, install cmake using pip install cmake. then install dlib using pip install dlib. dlib installs successfully

Current Behavior

i've already installed cmake through pip. when i try to install dlib through pip, it tries to find cmake to build the wheel, however it is not able to. cmake requirement is already satisfied. i am using a virtual envrinoment. cmake.exe is also present in venv/Scripts

Steps to Reproduce

install dlib

(venv) PS C:\myFiles\dev\Hair_Style_Recommendation> pip install dlib

pip throws the following error

Collecting dlib
  Using cached dlib-19.24.4.tar.gz (3.3 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]
      <string>:210: SyntaxWarning: invalid escape sequence '\('
      <string>:211: SyntaxWarning: invalid escape sequence '\('
      <string>:212: SyntaxWarning: invalid escape sequence '\('
      running bdist_wheel
      running build
      running build_ext
      Traceback (most recent call last):
        File "<frozen runpy>", line 198, in _run_module_as_main
        File "<frozen runpy>", line 88, in _run_code
        File "C:\myFiles\dev\Hair_Style_Recommendation\venv\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

so i then check if cmake is installed. it is already installed.

(venv) PS C:\myFiles\dev\Hair_Style_Recommendation> python -m pip install cmake
Requirement already satisfied: cmake in c:\myfiles\dev\hair_style_recommendation\venv\lib\site-packages (3.29.3)

cmake.exe is also present in venv/Scripts

(venv) PS C:\myFiles\dev\Hair_Style_Recommendation> Test-path "venv\Scripts\cmake.exe"
True

however, it still cannot find it and installation fails

Anything else?

i am using windows 11 23h2. python version 3.12.1. pip version 24.0. cmake version (from pip) 3.29.3

rickmaz commented 1 month ago

After you installed cmake did you try to do the dilib build in a new window session like a new command prompt. You should close that window and open a new one ideally with Administrator access. Also, you need visual studio installed to compile dlib with cmake also. Is cmake in your path? If you enter cmake --version for example does it show you the build number?

davisking commented 1 month ago

Open a windows command prompt and type cmake and hit enter. If it says command not found then cmake isn’t installed correctly. The copy of cmake in pip has been largely broken for years. You should install cmake from cmake.org. That will work and is the official place to get cmake. On Jun 2, 2024, at 8:45 AM, rickmaz @.***> wrote: After you installed cmake did you try to do the dilib build in a new window session like a new command prompt. You should close that window and open a new one ideally with Administrator access. Also, you need visual studio installed to compile dlib with cmake also. Is cmake in your path? If you enter cmake --version for example does it show you the build number?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

lefteryx commented 1 month ago

Hi, installing cmake from apt works, yes, but for whatever reason, dlib=19.24.2 can be installed using the pip cmake but not dlib=19.24.4. I'm not sure what the particular reason for this is though.

atharva-p commented 1 month ago

@davisking checked if cmake is in path, and it is

PS C:\Users\athar> cmake --version
cmake version 3.28.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

also i can build dlib with cmake but then can i use it with virtual environment that way? when i researched i got answers saying that i can't.

atharva-p commented 1 month ago

@lefteryx i tried it out, and dlib 19.24.2 installs with pip cmake, however dlib 19.24.4 (latest) does not work

davisking commented 3 weeks ago

I'm not able to reproduce this. For me pip install dlib installs 19.24.4 without any issue. I'm guessing something is broken about your cmake install. You will have to debug it :shrug:

Note that that error is saying cmake isn't in your PATH. You have to install cmake on your computer such that cmake is in your PATH so that programs can run cmake and not get an error about cmake not being available.

lefteryx commented 3 weeks ago

Just to confirm and make sure we're on the same page, I meant that I can install dlib=19.24.2 using the pip cmake only without having the apt cmake or Visual Studio. Instaling dlib=19.24.4 does not work with ONLY pip install cmake and instead requires apt cmake. Thanks for your response btw!

davisking commented 3 weeks ago

@lefteryx that's probably due to https://github.com/davisking/dlib/pull/2878

lefteryx commented 3 weeks ago

Oh that is probably it, thank you very much for your response!

dishuostec commented 3 weeks ago

Just to confirm and make sure we're on the same page, I meant that I can install dlib=19.24.2 using the pip cmake only without having the apt cmake or Visual Studio. Instaling dlib=19.24.4 does not work with ONLY pip install cmake and instead requires apt cmake. Thanks for your response btw!

Confirmed. I run pip install cmake then pip install dlib, and i got same error above. After pip uninstall cmake and sudo apt install cmake, I can install dlib without any error.

dhruv-yadav-nitj commented 1 week ago

What worked for me: [Windows]

  1. python v 3.8 ( i tried with 3.12, but did not worked)
  2. ensure that you have installed cmake in your venv before installing dlib
  3. download dlib-19.22.99-cp38-cp38-win_amd64.whl
  4. copy and paste the file 'dlib-19.22.99-cp38-cp38-win_amd64.whl' file in your project/venv/Scripts folder
  5. open project/venv/Scripts folder in terminal and pip install dlib-19.22.99-cp38-cp38-win_amd64.whl

if still this did not work then install Visual C++ from microsoft website, restart pc and try again!

prathap1425 commented 1 week ago

Hi, installing cmake from apt works, yes, but for whatever reason, dlib=19.24.2 can be installed using the pip cmake but not dlib=19.24.4. I'm not sure what the particular reason for this is though.

same i cant find the reason why i cant able to install this dlib=19.12.4.

313177606 commented 1 week ago

Same problem. wt do ?

davisking commented 6 days ago

If you open a terminal window and type cmake and hit enter what happens? I'm talking about the same terminal window you would use to install dlib. If when you type cmake in that window you get an error about cmake not being found then it's not installed correctly. So you have to install cmake such that opening a terminal window and typing cmake and hitting enter doesn't give an error. On windows the simplest way to do that is to use the installer from cmake.org.

To say that real clearly, in whatever window you use to type the install command for dlib. First just type cmake and hit enter. If you get an error stop and do not attempt to install dlib. First get cmake installed.