0

I am writing a Django React web app and I am required to install Dlib for a specific component to work (to install face_recognition library). However I am unable to do so because I used Python 3.12 to create the virtual env whereas Dlib and Cmake only support up to Python 2.9, hence I am unable to install Dlib to my venv. I am using Windows 10 x64 Operating System.

Is there a way to change the Python version of the virtual environment?

Or what else can I do to install Dlib? Without losing progress?

I really don’t feel like starting over with a new venv made with Python 2.9 because I am almost halfway through development. Thanks in advance.

This is the error code I get when trying to install face_recognition using VSCode ->

Downloading face_recognition-1.3.0-py2.py3-none-any.whl (15 kB)
Building wheels for collected packages: dlib, face-recognition-models
  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:\Users\User\Documents\GitHub\codecalm-repo\env\Scripts\cmake.exe\__main__.py", line 4, in <module>
      ModuleNotFoundError: No module named 'cmake'
     
      ERROR: CMake must be installed to build dlib
     

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for dlib
  Building wheel for face-recognition-models (setup.py) ... done
  Created wheel for face-recognition-models: filename=face_recognition_models-0.3.0-py2.py3-none-any.whl size=100566177 sha256=aea7948d7665696bbfc72f6aa9a1effe5c2ce1842746857937991bf958f27648
  Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\8f\47\c8\f44c5aebb7507f7c8a2c0bd23151d732d0f0bd6884ad4ac635
Successfully built face-recognition-models
Failed to build dlib
ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects
4
  • The question is inside out. You can't change an existing virtual environment but you can easily create new ones, as many as you like, with whatever parameters you like. However, 2.7 did not have a built-in venv module, so you need a third-party one, like virtualenv.
    – tripleee
    Commented Jul 4 at 10:06
  • 3
    There is no Python 2.9; the last 2.x release was 2.7.
    – tripleee
    Commented Jul 4 at 10:06
  • dlib wheels (.whl) are available for multiple Python versions up to and including 3.12
    – SIGHUP
    Commented Jul 4 at 12:31
  • The error messages here indicate that you need to install cmake. They don't say anything about python version. The dlib website and/or setup.py suggest you need to install cmake 3.1.0, and that pip won't work. You'll have to install in the OS, I guess. Commented Jul 6 at 18:09

0

Browse other questions tagged or ask your own question.