-1

I am installing dlib for python 3 following this because pip doesn't work, and I am installing it from source file (setup.py). But, an error occured:

-- 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\TIN\Downloads\dlib\dlib-19.22.0\setup.py", line 222, in <module>
    setup(
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py", line 67, in run
    self.do_egg_install()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install.py", line 109, in do_egg_install
    self.run_command('bdist_egg')
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 164, in run
    cmd = self.call_command('install_lib', warn_dir=0)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\bdist_egg.py", line 150, in call_command
    self.run_command(cmdname)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\site-packages\setuptools\command\install_lib.py", line 11, in run
    self.build()
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\command\install_lib.py", line 107, in build
    self.run_command('build_ext')
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\TIN\Downloads\dlib\dlib-19.22.0\setup.py", line 134, in run
    self.build_extension(ext)
  File "C:\Users\TIN\Downloads\dlib\dlib-19.22.0\setup.py", line 171, in build_extension
    subprocess.check_call(cmake_setup, cwd=build_folder)
  File "C:\Users\TIN\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\TIN\\Downloads\\dlib\\dlib-19.22.0\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\TIN\\Downloads\\dlib\\dlib-19.22.0\\build\\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=C:\\Users\\TIN\\AppData\\Local\\Programs\\Python\\Python39\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\TIN\\Downloads\\dlib\\dlib-19.22.0\\build\\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.

How to fix this problem? Also, I am on Python 3.9.4. And, it seems like I need to install Visual Studio for C++. But where can I find that?

khgb
  • 174
  • 1
  • 12
  • `it seems like I need to install Visual Studio for C++. But where can I find that?` → https://visualstudio.microsoft.com/vs/features/cplusplus/ – rzlvmp Aug 13 '21 at 02:08
  • The error log is self-explanatory. You must install Visual Studio for C++ for "Compilers, build tools and runtimes" as the answer of @Rajat Bhatt on the link you provided. I believe the time you spend reading all the answers is surely shorter than the amount of time writing a new question + waiting for someone to help. – Lê Quang Duy Aug 13 '21 at 02:20
  • https://stackoverflow.com/search?q=%5Bdlib%5D+You+must+use+Visual+Studio+to+build+a+python+extension+on+windows – phd Aug 13 '21 at 09:15

1 Answers1

1

Many binaries depend on Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019 for Python 3

so, please try to use the following codes to solve it

pip install --upgrade setuptools

if you are not succeed to solve this problem,

then you can try to use this link The latest supported Visual C++ downloads to solve this problem

Hong Cheng
  • 318
  • 1
  • 4
  • 19