i cant download dlib using pip

60 Views Asked by At

ive tried almost everything I can yt vids other stack overflow questions but the terminal just says this:

PS C:\Users\ADMIN-200523\Desktop\New folder (2)> pip install dlib
Collecting 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.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
      Invoking CMake setup: 'cmake C:\Users\ADMIN-200523\AppData\Local\Temp\pip-install-idm12bp9\dlib_cfac82ac5458446ea50c05264a43db94\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\ADMIN-200523\AppData\Local\Temp\pip-install-idm12bp9\dlib_cfac82ac5458446ea50c05264a43db94\build\lib.win-amd64-cpython-312 -DPYTHON_EXECUTABLE=C:\Python312\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\ADMIN-200523\AppData\Local\Temp\pip-install-idm12bp9\dlib_cfac82ac5458446ea50c05264a43db94\build\lib.win-amd64-cpython-312 -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\ADMIN-200523\AppData\Roaming\Python\Python312\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\ADMIN-200523\AppData\Roaming\Python\Python312\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\ADMIN-200523\AppData\Roaming\Python\Python312\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\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\build_meta.py", line 404, in build_wheel
          return self._build_with_temp_dir(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\build_meta.py", line 389, in _build_with_temp_dir
          self.run_setup()
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\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\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\__init__.py", line 103, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
          dist.run_commands()
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
          super().run_command(command)
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
          cmd_obj.run()
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 368, in run
          self.run_command("build")
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
          super().run_command(command)
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
          cmd_obj.run()
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\command\build.py", line 131, in run
          self.run_command(cmd_name)
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\overlay\Lib\site-packages\setuptools\dist.py", line 963, in run_command
          super().run_command(command)
        File "C:\Users\ADMIN-200523\AppData\Local\Temp\pip-build-env-r93gxw78\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:\Python312\Lib\subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\ADMIN-200523\\AppData\\Local\\Temp\\pip-install-idm12bp9\\dlib_cfac82ac5458446ea50c05264a43db94\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\ADMIN-200523\\AppData\\Local\\Temp\\pip-install-idm12bp9\\dlib_cfac82ac5458446ea50c05264a43db94\\build\\lib.win-amd64-cpython-312', '-DPYTHON_EXECUTABLE=C:\\Python312\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\ADMIN-200523\\AppData\\Local\\Temp\\pip-install-idm12bp9\\dlib_cfac82ac5458446ea50c05264a43db94\\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     
PS C:\Users\ADMIN-200523\Desktop\New folder (2)> 

ive tried asking chatgpt and tried to find tutorials but I cant find ANYTHING

i am using it to make a simple program too here is the program:

import cv2
import face_recognition

# Function to predict emotion, age, and gender for a given face image
def predict_attributes(face_image):
    # Implement your models for emotion, age, and gender prediction here
    mood = "Unknown"
    age = "Unknown"
    gender = "Unknown"
    # You need to replace the above lines with your actual prediction logic

    return mood, age, gender

# Open the camera
cap = cv2.VideoCapture(0)

while True:
    # Capture frame-by-frame
    ret, frame = cap.read()

    # Find face locations in the frame
    face_locations = face_recognition.face_locations(frame)

    for face_location in face_locations:
        top, right, bottom, left = face_location
        face_image = frame[top:bottom, left:right]

        # Predict emotion, age, and gender
        mood, age, gender = predict_attributes(face_image)

        # Draw rectangle around the face
        cv2.rectangle(frame, (left, top), (right, bottom), (0, 255, 0), 2)

        # Display predicted attributes
        cv2.putText(frame, f"Mood: {mood}", (left, bottom + 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
        cv2.putText(frame, f"Age: {age}", (left, bottom + 40), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
        cv2.putText(frame, f"Gender: {gender}", (left, bottom + 60), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

    # Display the resulting frame
    cv2.imshow('Video', frame)

    # Break the loop when 'q' key is pressed
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# Release the camera and close all windows
cap.release()
cv2.destroyAllWindows()

please help tell me the problem as i am still new to python and im very confused

0

There are 0 best solutions below