Closed1

uv で face_recognition をいれるのに苦労した備忘録

HashoryHashory

まずは、、

Command
uv add face_recognition

...だけじゃ駄目でした。

1. cmakeとC++をビルドするツールを入れる。

これは、いろんな記事で触れられている通りです。 face_recognition が依存している dlib がビルドを必要とする見たいので入れます。

Windows なので Visual Studio を入れ、Cmake も入れてあげます。
Cmake はインストーラーが PATH を通してくれないと書いてあったのですが、Winget から入れたら通ってました。

この時点では問題なし

2. なぞのエラーがでる。

Error
error: Failed to prepare distributions
  Caused by: Failed to fetch wheel: dlib==19.24.6
  Caused by: Build backend failed to build wheel through `build_wheel()` with exit code: 1
--- stdout:
running bdist_wheel
running build
running build_ext
Building extension for Python 3.12.4 (tags/v3.12.4:8e8a4ba, Jun  6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]
Invoking CMake setup: 'cmake C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\lib.win-amd64-cpython-312 -DPYTHON_EXECUTABLE=C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Scripts\python.exe -DDLIB_USE_FFMPEG=OFF -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\lib.win-amd64-cpython-312 -A x64'
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.40.33808.0
-- The CXX compiler identification is MSVC 19.40.33808.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - broken
-- Configuring incomplete, errors occurred!
--- stderr:
<string>:234: SyntaxWarning: invalid escape sequence '\('
<string>:235: SyntaxWarning: invalid escape sequence '\('
<string>:236: SyntaxWarning: invalid escape sequence '\('
<string>:163: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
CMake Error at C:/Program Files/CMake/share/cmake-3.30/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: 'C:/Users/user/AppData/Local/uv/cache/sdists-v4/pypi/dlib/19.24.6/CQySO4trWncSRXX7Zamey/dlib-19.24.6.tar.gz/build/temp.win-amd64-cpython-312/Release/CMakeFiles/CMakeScratch/TryCompile-yo6lnm'

    Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/2022/Community/MSBuild/Current/Bin/amd64/MSBuild.exe" cmTC_73d66.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n
    MSBuild 縺ョ繝舌・繧ク繝ァ繝ウ 17.10.4+10fbfbf2e (.NET Framework)
    2024/10/19 23:34:29 縺ォ繝薙Ν繝峨r髢句ァ九@縺セ縺励◆縲・

    繝弱・繝・1 荳翫・繝励Ο繧ク繧ァ繧ッ繝・"C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj" (譌「螳壹・繧ソ繝シ繧イ繝・ヨ)縲・
    PrepareForBuild:
      繝・ぅ繝ャ繧ッ繝医Μ "cmTC_73d66.dir\Debug\" 繧剃ス懈・縺励※縺・∪縺吶・
      讒矩蛹門・蜉帙′譛牙柑縺ォ縺ェ縺」縺ヲ縺・∪縺吶ゅさ繝ウ繝代う繝ゥ險コ譁ュ縺ョ譖ク蠑剰ィュ螳壹↓縺ッ繧ィ繝ゥ繝シ髫主ア、縺悟渚譏縺輔l縺セ縺吶りゥウ邏ー縺ォ縺、縺・※縺ッ縲”ttps://aka.ms/cpp/structured-output 繧貞盾辣ァ縺励※縺上□縺輔>縲・
      繝・ぅ繝ャ繧ッ繝医Μ "C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\Debug\" 繧剃ス懈・縺励※縺・∪縺吶・
      繝・ぅ繝ャ繧ッ繝医Μ "cmTC_73d66.dir\Debug\cmTC_73d66.tlog\" 繧剃ス懈・縺励※縺・∪縺吶・
    InitializeBuildStatus:
      "AlwaysCreate" 縺梧欠螳壹&繧後◆縺溘a "cmTC_73d66.dir\Debug\cmTC_73d66.tlog\unsuccessfulbuild" 繧剃ス懈・縺励※縺・∪縺吶・
      "cmTC_73d66.dir\Debug\cmTC_73d66.tlog\unsuccessfulbuild" 縺ョ繧ソ繝・メ 繧ソ繧ケ繧ッ繧貞ョ溯。後@縺ヲ縺・∪縺吶・
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018: "GetOutOfDateItems" 繧ソ繧ケ繧ッ縺御コ域悄縺帙★縺ォ螟ア謨励@縺セ縺励◆縲・[C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018: System.InvalidOperationException: 鬆・岼繝。繧ソ繝・・繧ソ "%(FullPath)" 繧偵ヱ繧ケ "cmTC_73d66.dir\Debug\cmTC_73d66.tlog\ParallelCustomBuild.read.1.tlog" 縺ォ驕ゥ逕ィ縺ァ縺阪∪縺帙s縲ゅヱ繧ケ: cmTC_73d66.dir\Debug\cmTC_73d66.tlog\ParallelCustomBuild.read.1.tlog 縺ッ OS 縺ョ繝代せ縺ョ荳企剞繧定カ翫∴縺ヲ縺・∪縺吶ょョ悟・菫ョ鬟セ縺ョ繝輔ぃ繧、繝ォ蜷阪・ 260 譁・ュ嶺サ・荳九↓縺吶k蠢・ヲ√′縺ゅj縺セ縺吶・[C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Shared.FileUtilities.ItemSpecModifiers.GetItemSpecModifier(String currentDirectory, String itemSpec, String definingProjectEscaped, String modifier, String& fullPath) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]   
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Utilities.TaskItem.Microsoft.Build.Framework.ITaskItem2.GetMetadataValueEscaped(String metadataName) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Utilities.TaskItem.GetMetadata(String metadataName) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.CPPTasks.GetOutOfDateItems.Execute() [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    繝励Ο繧ク繧ァ繧ッ繝・"C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj" (譌「螳壹・繧ソ繝シ繧イ繝・ヨ) 縺ョ繝薙Ν繝峨′邨ゆコ・@縺セ縺励◆ -- 螟ア謨励・

    繝薙Ν繝峨↓螟ア謨励@縺セ縺励◆縲・

    "C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj" (譌「螳壹・繧ソ繝シ繧イ繝・ヨ) (1) ->
    (CustomBuild 繧ソ繝シ繧イ繝・ヨ) ->
      C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018: "GetOutOfDateItems" 繧ソ繧ケ繧ッ縺御コ域悄縺帙★縺ォ螟ア謨励@縺セ縺励◆縲・[C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018: System.InvalidOperationException: 鬆・岼繝。繧ソ繝・・繧ソ "%(FullPath)" 繧偵ヱ繧ケ "cmTC_73d66.dir\Debug\cmTC_73d66.tlog\ParallelCustomBuild.read.1.tlog" 縺ォ驕ゥ逕ィ縺ァ縺阪∪縺帙s縲ゅヱ繧ケ: cmTC_73d66.dir\Debug\cmTC_73d66.tlog\ParallelCustomBuild.read.1.tlog 縺ッ OS 縺ョ繝代せ縺ョ荳企剞繧定カ翫∴縺ヲ縺・∪縺吶ょョ悟・菫ョ鬟セ縺ョ繝輔ぃ繧、繝ォ蜷阪・ 260 譁・ュ嶺サ・荳九↓縺吶k蠢・ヲ√′縺ゅj縺セ縺吶・[C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Shared.FileUtilities.ItemSpecModifiers.GetItemSpecModifier(String currentDirectory, String itemSpec, String definingProjectEscaped, String modifier, String& fullPath) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]   
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Utilities.TaskItem.Microsoft.Build.Framework.ITaskItem2.GetMetadataValueEscaped(String metadataName) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.Utilities.TaskItem.GetMetadata(String metadataName) [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.CPPTasks.GetOutOfDateItems.Execute() [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]
    C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(203,5): error MSB4018:    蝣エ謇 Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Users\user\AppData\Local\uv\cache\sdists-v4\pypi\dlib\19.24.6\CQySO4trWncSRXX7Zamey\dlib-19.24.6.tar.gz\build\temp.win-amd64-cpython-312\Release\CMakeFiles\CMakeScratch\TryCompile-yo6lnm\cmTC_73d66.vcxproj]

        0 蛟九・隴ヲ蜻・
        1 繧ィ繝ゥ繝シ

    邨碁℃譎る俣 00:00:00.21





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:14 (project)


Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\build_meta.py", line 431, in build_wheel
    return _build(['bdist_wheel'])
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\build_meta.py", line 422, in _build
    return self._build_with_temp_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\build_meta.py", line 403, in _build_with_temp_dir
    self.run_setup()
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\build_meta.py", line 516, in run_setup
    super().run_setup(setup_script=setup_script)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\build_meta.py", line 318, in run_setup
    exec(code, locals())
  File "<string>", line 243, in <module>
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\__init__.py", line 117, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\core.py", line 183, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\core.py", line 199, in run_commands
    dist.run_commands()
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\dist.py", line 954, in run_commands
    self.run_command(cmd)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\dist.py", line 991, in run_command
    super().run_command(command)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
    cmd_obj.run()
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\command\bdist_wheel.py", line 407, in run
    self.run_command("build")
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command
    self.distribution.run_command(command)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\dist.py", line 991, in run_command
    super().run_command(command)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
    cmd_obj.run()
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\cmd.py", line 316, in run_command
    self.distribution.run_command(command)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\dist.py", line 991, in run_command
    super().run_command(command)
  File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmpkORGAF\Lib\site-packages\setuptools\_distutils\dist.py", line 973, in run_command
    cmd_obj.run()
  File "<string>", line 168, in run
  File "<string>", line 206, in build_extension
  File "C:\Users\user\AppData\Local\Programs\Python\Python312\Lib\subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\user\\AppData\\Local\\uv\\cache\\sdists-v4\\pypi\\dlib\\19.24.6\\CQySO4trWncSRXX7Zamey\\dlib-19.24.6.tar.gz\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\user\\AppData\\Local\\uv\\cache\\sdists-v4\\pypi\\dlib\\19.24.6\\CQySO4trWncSRXX7Zamey\\dlib-19.24.6.tar.gz\\build\\lib.win-amd64-cpython-312', '-DPYTHON_EXECUTABLE=C:\\Users\\user\\AppData\\Local\\uv\\cache\\builds-v0\\.tmpkORGAF\\Scripts\\python.exe', '-DDLIB_USE_FFMPEG=OFF', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\user\\AppData\\Local\\uv\\cache\\sdists-v4\\pypi\\dlib\\19.24.6\\CQySO4trWncSRXX7Zamey\\dlib-19.24.6.tar.gz\\build\\lib.win-amd64-cpython-312', '-A', 'x64']' returned non-zero exit status 1.
---

dlib のビルドが始まってから出てきます。 MSVC が出してるのはよくわかります。
エラー文字化けしてるし、uv を使わず、pip で入れると出てこないのでちょっと手こずりました。

原因:

Windows のパスの長さが260文字に制限されているため。

pip でエラーが発生しないのは260字で足りていたからと思われる。uv はキャッシュやらでパスの階層が深くなりがちってことだと思う。

解決方法:

制限を解除した。

  • レジストリエディタの起動
  • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem に移動
  • LongPathsEnabled1 に変更
  • 再起動

3. 繰り返される face_recognition_modelsをインストールせい

import face_recognition の書かれたファイルを実行すると、以下のように出ます:

出るもの
Please install `face_recognition_models` with this command before using `face_recognition`:

pip install git+https://github.com/ageitgey/face_recognition_models

素直にインストールします:

Command
uv add git+https://github.com/ageitgey/face_recognition_models

もう一度実行します:

出るもの
Please install `face_recognition_models` with this command before using `face_recognition`:

pip install git+https://github.com/ageitgey/face_recognition_models

何回やっても出ます。

実行コマンドに キャッシュのリフレッシュ(--refresh) や ノーキャッシュ(--no-cache) をつけてもダメでした。

解決方法:

事前に setuptools を導入します。

Command
uv add setuptools

face_recognition_models を入れ直す。

Command
uv add git+https://github.com/ageitgey/face_recognition_models

✅ Compleate!

完了! (最後までお付き合いありがとうございます)

このスクラップは28日前にクローズされました