"ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects" while installing dlib in PowerShell

huangapple go评论214阅读模式
英文:

"ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects" while installing dlib in PowerShell

问题

我已经构建了一个人脸识别工具,我正在尝试安装dlib。

每次我尝试安装dlib时,我都会收到这条消息:

  │ exit code: 1
  ╰─> [78 lines of output]
      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.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
      Invoking CMake setup: 'cmake C:\Users\Jack\AppData\Local\Temp\pip-install-tl9fdcf0\dlib_fee2183dfbb9404395bfedaca5728c1a\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Jack\AppData\Local\Temp\pip-install-tl9fdcf0\dlib_fee2183dfbb9404395bfedaca5728c1a\build\lib.win-amd64-cpython-311 -DPYTHON_EXECUTABLE=C:\Users\Jack\AppData\Local\Programs\Python\Python311\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Jack\AppData\Local\Temp\pip-install-tl9fdcf0\dlib_fee2183dfbb9404395bfedaca5728c1a\build\lib.win-amd64-cpython-311 -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\Jack\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\Jack\AppData\Local\Programs\Python\Python311\Lib\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\Jack\AppData\Local\Programs\Python\Python311\Lib\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\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\build_meta.py", line 416, in build_wheel
          return self._build_with_temp_dir(['bdist_wheel'], '.whl',
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\build_meta.py", line 401, in _build_with_temp_dir
          self.run_setup()
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\build_meta.py", line 338, in run_setup
          exec(code, locals())
        File "<string>", line 218, in <module>
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\__init__.py", line 107, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\core.py", line 201, in run_commands
          dist.run_commands()
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\dist.py", line 1234, in run_command
          super().run_command(command)
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command
          cmd_obj.run()
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\wheel\bdist_wheel.py", line 343, in run
          self.run_command("build")
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 318, in run_command
          self.distribution.run_command(command)
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\dist.py", line 1234, in run_command
          super().run_command(command)
        File "C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 988, in run_command

<details>
<summary>英文:</summary>

I have been building a facial recognition tool and I am trying to install dlib.

Every time I have tried to install dlib, I get this message:

× Building wheel for dlib (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [78 lines of output]
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.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\Jack\AppData\Local\Temp\pip-install-tl9fdcf0\dlib_fee2183dfbb9404395bfedaca5728c1a\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\Jack\AppData\Local\Temp\pip-install-tl9fdcf0\dlib_fee2183dfbb9404395bfedaca5728c1a\build\lib.win-amd64-cpython-311 -DPYTHON_EXECUTABLE=C:\Users\Jack\AppData\Local\Programs\Python\Python311\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\Jack\AppData\Local\Temp\pip-install-tl9fdcf0\dlib_fee2183dfbb9404395bfedaca5728c1a\build\lib.win-amd64-cpython-311 -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 &quot;C:\Users\Jack\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py&quot;, line 353, in &lt;module&gt;
      main()
    File &quot;C:\Users\Jack\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py&quot;, line 335, in main
      json_out[&#39;return_val&#39;] = hook(**hook_input[&#39;kwargs&#39;])
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File &quot;C:\Users\Jack\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py&quot;, line 251, in build_wheel
      return _build_backend().build_wheel(wheel_directory, config_settings,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\build_meta.py&quot;, line 416, in build_wheel
      return self._build_with_temp_dir([&#39;bdist_wheel&#39;], &#39;.whl&#39;,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\build_meta.py&quot;, line 401, in _build_with_temp_dir
      self.run_setup()
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\build_meta.py&quot;, line 338, in run_setup
      exec(code, locals())
    File &quot;&lt;string&gt;&quot;, line 218, in &lt;module&gt;
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\__init__.py&quot;, line 107, in setup
      return distutils.core.setup(**attrs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\core.py&quot;, line 185, in setup
      return run_commands(dist)
             ^^^^^^^^^^^^^^^^^^
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\core.py&quot;, line 201, in run_commands
      dist.run_commands()
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\dist.py&quot;, line 969, in run_commands
      self.run_command(cmd)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\dist.py&quot;, line 1234, in run_command
      super().run_command(command)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\dist.py&quot;, line 988, in run_command
      cmd_obj.run()
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\wheel\bdist_wheel.py&quot;, line 343, in run
      self.run_command(&quot;build&quot;)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\cmd.py&quot;, line 318, in run_command
      self.distribution.run_command(command)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\dist.py&quot;, line 1234, in run_command
      super().run_command(command)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\dist.py&quot;, line 988, in run_command
      cmd_obj.run()
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\command\build.py&quot;, line 131, in run
      self.run_command(cmd_name)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\cmd.py&quot;, line 318, in run_command
      self.distribution.run_command(command)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\dist.py&quot;, line 1234, in run_command
      super().run_command(command)
    File &quot;C:\Users\Jack\AppData\Local\Temp\pip-build-env-ar6t1xkr\overlay\Lib\site-packages\setuptools\_distutils\dist.py&quot;, line 988, in run_command
      cmd_obj.run()
    File &quot;&lt;string&gt;&quot;, line 130, in run
    File &quot;&lt;string&gt;&quot;, line 167, in build_extension
    File &quot;C:\Users\Jack\AppData\Local\Programs\Python\Python311\Lib\subprocess.py&quot;, line 413, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command &#39;[&#39;cmake&#39;, &#39;C:\\Users\\Jack\\AppData\\Local\\Temp\\pip-install-tl9fdcf0\\dlib_fee2183dfbb9404395bfedaca5728c1a\\tools\\python&#39;, &#39;-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\Jack\\AppData\\Local\\Temp\\pip-install-tl9fdcf0\\dlib_fee2183dfbb9404395bfedaca5728c1a\\build\\lib.win-amd64-cpython-311&#39;, &#39;-DPYTHON_EXECUTABLE=C:\\Users\\Jack\\AppData\\Local\\Programs\\Python\\Python311\\python.exe&#39;, &#39;-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\Jack\\AppData\\Local\\Temp\\pip-install-tl9fdcf0\\dlib_fee2183dfbb9404395bfedaca5728c1a\\build\\lib.win-amd64-cpython-311&#39;, &#39;-A&#39;, &#39;x64&#39;]&#39; 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

I have already installed CMake the correct way. Visual Studio is also installed. How do I fix this error?

</details>


# 答案1
**得分**: 1

看起来你正在使用Python 3.11。我找到了适用于Python版本3.7、3.8和3.9的解决方案:

1. 克隆或下载这个[仓库][1]。
2. 通过[Python venv][2]或[Anaconda][3]创建一个虚拟环境,例如`conda create -n your_env python=3.8`。我已经测试过Python 3.8可以工作。
3. 进入你克隆或下载仓库的目录。
4. 运行以下命令:`pip install dlib-19.22.99-cp38-cp38-win_amd64.whl`

这应该可以帮助你安装dlib 19.22.99!

[1]: https://github.com/sachadee/Dlib
[2]: https://docs.python.org/3/library/venv.html
[3]: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

<details>
<summary>英文:</summary>

It looks like you are using Python 3.11. I found a solution which works for Python versions: 3.7, 3.8 and 3.9: 

 1. Clone or download this [repo.][1] 
 2. Create a virtual environment via [Python venv][2] or [Anaconda][3] i.e. `conda create -n your_env python = 3.8`. I tested with Python 3.8 and it works.
3. Go to the directory where you cloned/downloaded the repo. 
4. Run the following: `pip install dlib-19.22.99-cp38-cp38-win_amd64.whl`

This should help you to install dlib 19.22.99! 


  [1]: https://github.com/sachadee/Dlib
  [2]: https://docs.python.org/3/library/venv.html
  [3]: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html

</details>



huangapple
  • 本文由 发表于 2023年7月6日 21:51:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76629574.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定