我正在安装python 3的dlib,因为pip不起作用,我正在从源文件(setup.py)安装它。但是,出现错误:
-- 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:UsersTINDownloadsdlibdlib-19.22.0setup.py", line 222, in <module>
setup(
File "C:UsersTINAppDataLocalProgramsPythonPython39libsite-packagessetuptools__init__.py", line 153, in setup
return distutils.core.setup(**attrs)
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilscore.py", line 148, in setup
dist.run_commands()
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilsdist.py", line 966, in run_commands
self.run_command(cmd)
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "C:UsersTINAppDataLocalProgramsPythonPython39libsite-packagessetuptoolscommandinstall.py", line 67, in run
self.do_egg_install()
File "C:UsersTINAppDataLocalProgramsPythonPython39libsite-packagessetuptoolscommandinstall.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilscmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "C:UsersTINAppDataLocalProgramsPythonPython39libsite-packagessetuptoolscommandbdist_egg.py", line 164, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "C:UsersTINAppDataLocalProgramsPythonPython39libsite-packagessetuptoolscommandbdist_egg.py", line 150, in call_command
self.run_command(cmdname)
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilscmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "C:UsersTINAppDataLocalProgramsPythonPython39libsite-packagessetuptoolscommandinstall_lib.py", line 11, in run
self.build()
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilscommandinstall_lib.py", line 107, in build
self.run_command('build_ext')
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilscmd.py", line 313, in run_command
self.distribution.run_command(command)
File "C:UsersTINAppDataLocalProgramsPythonPython39libdistutilsdist.py", line 985, in run_command
cmd_obj.run()
File "C:UsersTINDownloadsdlibdlib-19.22.0setup.py", line 134, in run
self.build_extension(ext)
File "C:UsersTINDownloadsdlibdlib-19.22.0setup.py", line 171, in build_extension
subprocess.check_call(cmake_setup, cwd=build_folder)
File "C:UsersTINAppDataLocalProgramsPythonPython39libsubprocess.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.
如何解决这个问题?另外,我使用Python 3.9.4。而且,我似乎需要为c++安装Visual Studio。但是我到哪里去找呢?
许多二进制文件依赖于Microsoft Visual c++ Redistributable for Visual Studio 2015、2017和2019 for Python 3
所以,请尝试使用下面的代码来解决它
pip install --upgrade setuptools
如果你不能成功地解决这个问题,
那么你可以尝试使用这个链接最新支持的Visual c++下载来解决这个问题