为啥我在安装 dlib 时收到此错误“检查日志以获取完整的命令输出”?

Posted

技术标签:

【中文标题】为啥我在安装 dlib 时收到此错误“检查日志以获取完整的命令输出”?【英文标题】:why i'm getting this error "check the logs for full command output" when i'm installing dlib?为什么我在安装 dlib 时收到此错误“检查日志以获取完整的命令输出”? 【发布时间】:2021-04-07 08:14:13 【问题描述】:

我正在尝试在 vertual studio 代码上安装 dlib,但显示以下错误:

 Running setup.py install for dlib ... error
    ERROR: Command errored out with exit status 1:
     command: 'c:\users\acer\appdata\local\programs\python\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ACER\\AppData\\Local\\Temp\\pip-install-iotpp637\\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\\setup.py'"'"'; __file__='"'"'C:\\Users\\ACER\\AppData\\Local\\Temp\\pip-install-iotpp637\\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ACER\AppData\Local\Temp\pip-record-qzdzy48q\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\acer\appdata\local\programs\python\python39\Include\dlib'
         cwd: C:\Users\ACER\AppData\Local\Temp\pip-install-iotpp637\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\   
    Complete output (60 lines):
    running install
    running build
    running build_py
    package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
    running build_ext
    Building extension for Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
    Invoking CMake setup: 'cmake C:\Users\ACER\AppData\Local\Temp\pip-install-iotpp637\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\ACER\AppData\Local\Temp\pip-install-iotpp637\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\build\lib.win-amd64-3.9 -DPYTHON_EXECUTABLE=c:\users\acer\appdata\local\programs\python\python39\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\ACER\AppData\Local\Temp\pip-install-iotpp637\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\build\lib.win-amd64-3.9 -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 "<string>", line 1, in <module>
      File "C:\Users\ACER\AppData\Local\Temp\pip-install-iotpp637\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\setup.py", line 223, in <module>
        setup(
      File "c:\users\acer\appdata\local\programs\python\python39\lib\site-packages\setuptools\__init__.py", line 165, in setup
        return distutils.core.setup(**attrs)
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\core.py", line 148, in setup  
        dist.run_commands()
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\acer\appdata\local\programs\python\python39\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\command\install.py", line 546, in run
        self.run_command('build')
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "c:\users\acer\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "C:\Users\ACER\AppData\Local\Temp\pip-install-iotpp637\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\setup.py", line 135, in run
        self.build_extension(ext)
      File "C:\Users\ACER\AppData\Local\Temp\pip-install-iotpp637\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\setup.py", line 172, in build_extension
        subprocess.check_call(cmake_setup, cwd=build_folder)
      File "c:\users\acer\appdata\local\programs\python\python39\lib\subprocess.py", line 373, in check_call 
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\ACER\\AppData\\Local\\Temp\\pip-install-iotpp637\\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\ACER\\AppData\\Local\\Temp\\pip-install-iotpp637\\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\\build\\lib.win-amd64-3.9', '-DPYTHON_EXECUTABLE=c:\\users\\acer\\appdata\\local\\programs\\python\\python39\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\ACER\\AppData\\Local\\Temp\\pip-install-iotpp637\\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\\build\\lib.win-amd64-3.9', '-A', 'x64']' returned non-zero exit status 1.
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\acer\appdata\local\programs\python\python39\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ACER\\AppData\\Local\\Temp\\pip-install-iotpp637\\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\\setup.py'"'"'; __file__='"'"'C:\\Users\\ACER\\AppData\\Local\\Temp\\pip-install-iotpp637\\dlib_cbdb8998ebb54dee8cad48a70a8a0f3c\\setup.py'"'"';f=getattr(tokenize, 
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\ACER\AppData\Local\Temp\pip-record-qzdzy48q\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\acer\appdata\local\programs\python\python39\Include\dlib' Check the logs for full command output.

附加说明:我安装了cmake 并再次尝试但没有任何改变。

【问题讨论】:

请考虑将答案标记为已接受(答案左侧的灰色勾号),如果您觉得有用,请点赞。 【参考方案1】:

从您收到的错误消息中可以明显看出错误:

您必须使用 Visual Studio 在 Windows 上构建 Python 扩展。如果 你 收到此错误表示您尚未安装 Visual C++。笔记 有多种 Visual Studio 风格,例如 Visual Studio for C# 发展。您需要安装 Visual Studio for C++。

您需要从here 安装 *Visual Studio for C++ 并重新运行安装,以便构建 Python 的 C++ 扩展。

您可以避免在 dlib package is available 已经编译的地方使用 Anaconda(但目前不适用于 Python 3.9)。

【讨论】:

【参考方案2】:

您可以使用以下方法避免安装“Huge”IDE (VS) 或 Anaconda。

许多二进制文件依赖于 Microsoft Visual C++ Redistributable for Visual Studio 2015、2017 和 2019 for Python 3

所以,请尝试使用以下代码来解决它

pip install --upgrade setuptools

如果你没有成功解决这个问题,

那么你可以尝试使用这个链接The latest supported Visual C++ downloads来安装这个问题

【讨论】:

以上是关于为啥我在安装 dlib 时收到此错误“检查日志以获取完整的命令输出”?的主要内容,如果未能解决你的问题,请参考以下文章

为啥我在尝试访问此 WordPress 网站时收到此 403 Forbidden 错误?为啥它无法读取 .htaccess 文件?

为啥我在使用 isNull 时收到此错误消息

任何想法为啥我在添加声音时在精灵套件中收到此错误?

为啥我在使用 npm 时收到此错误,我该如何解决?

为啥我在尝试创建此表时不断收到外键错误? [复制]

为啥我在尝试运行我的 Twitter 天气机器人时会收到此错误