dlib不安装(cmake)

发布于 2025-01-19 16:15:40 字数 8279 浏览 0 评论 0原文

嗨,我正在尝试通过CMake安装DLIB,但我一直遇到错误:Legacy-install-failure 这是完整的读数 (我已经用用户替换了我的实际用户名)。 /strong>

>C:\Users\USER->pip install dlib
Collecting dlib
  Using cached dlib-19.23.1.tar.gz (7.4 MB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
  Running setup.py install for dlib ... error
  error: subprocess-exited-with-error
  × Running setup.py install for dlib did not run successfully.
  │ exit code: 1
  ╰─> [73 lines of output]
      running install
      C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
      running build_ext
      C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        if LooseVersion(cmake_version) < '3.1.0':
      Building extension for Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
      Invoking CMake setup: 'cmake C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\build\lib.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\USER-\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\build\lib.win-amd64-3.10 -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 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 222, in <module>
          setup(
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\__init__.py", line 79, in setup
          return distutils.core.setup(**attrs)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\core.py", line 148, in setup
          return run_commands(dist)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
          dist.run_commands()
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
          super().run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\command\install.py", line 68, in run
          return orig.install.run(self)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\command\install.py", line 670, in run
          self.run_command('build')
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
          super().run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\command\build.py", line 135, in run
          self.run_command(cmd_name)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
          super().run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 134, in run
          self.build_extension(ext)
        File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 171, in build_extension
          subprocess.check_call(cmake_setup, cwd=build_folder)
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\build\\lib.win-amd64-3.10', '-DPYTHON_EXECUTABLE=C:\\Users\\USER-\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\build\\lib.win-amd64-3.10', '-A', 'x64']' 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: legacy-install-failure
× Encountered error while trying to install package.
╰─> dlib
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

Hi I am trying to install dlib via cmake but I keep getting error: legacy-install-failure here is the full readout (I have replaced my actual user name with USER)

>C:\Users\USER->pip install dlib
Collecting dlib
  Using cached dlib-19.23.1.tar.gz (7.4 MB)
  Preparing metadata (setup.py) ... done
Using legacy 'setup.py install' for dlib, since package 'wheel' is not installed.
Installing collected packages: dlib
  Running setup.py install for dlib ... error
  error: subprocess-exited-with-error
  × Running setup.py install for dlib did not run successfully.
  │ exit code: 1
  ╰─> [73 lines of output]
      running install
      C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      package init file 'tools\python\dlib\__init__.py' not found (or not a regular file)
      running build_ext
      C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py:129: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
        if LooseVersion(cmake_version) < '3.1.0':
      Building extension for Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
      Invoking CMake setup: 'cmake C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\tools\python -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\build\lib.win-amd64-3.10 -DPYTHON_EXECUTABLE=C:\Users\USER-\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe -DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\build\lib.win-amd64-3.10 -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 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 222, in <module>
          setup(
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\__init__.py", line 79, in setup
          return distutils.core.setup(**attrs)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\core.py", line 148, in setup
          return run_commands(dist)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\core.py", line 163, in run_commands
          dist.run_commands()
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
          super().run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\command\install.py", line 68, in run
          return orig.install.run(self)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\command\install.py", line 670, in run
          self.run_command('build')
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
          super().run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\command\build.py", line 135, in run
          self.run_command(cmd_name)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\dist.py", line 1196, in run_command
          super().run_command(command)
        File "C:\Users\USER-\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\setuptools\_distutils\dist.py", line 986, in run_command
          cmd_obj.run()
        File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 134, in run
          self.build_extension(ext)
        File "C:\Users\USER-\AppData\Local\Temp\pip-install-q7gocxf3\dlib_ba1eccb06b884bc4a89365e82ab2b34f\setup.py", line 171, in build_extension
          subprocess.check_call(cmake_setup, cwd=build_folder)
        File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\subprocess.py", line 369, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['cmake', 'C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\tools\\python', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\build\\lib.win-amd64-3.10', '-DPYTHON_EXECUTABLE=C:\\Users\\USER-\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\python.exe', '-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE=C:\\Users\\USER-\\AppData\\Local\\Temp\\pip-install-q7gocxf3\\dlib_ba1eccb06b884bc4a89365e82ab2b34f\\build\\lib.win-amd64-3.10', '-A', 'x64']' 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: legacy-install-failure
× Encountered error while trying to install package.
╰─> dlib
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瘫痪情歌 2025-01-26 16:15:40

在PC上下载CMAKE可执行文件,安装并安装Visual Studio Build Tools为C ++安装CMAKE构建工具。使用Visual Studio构建工具安装CMAKE后,您需要从此github repo下载dlib wheel文件: https://github.com/tobyyosoba77777/computer-vision-vision-epencv-python-/tree/main/main/main/libraries

下载:下载:
dlib-12.22.99-cp39-cp39-win_amd64.whl

和下载:
dlib-129.22.99.win-amd64-py3.9.exe

在PC上安装.exe文件,重新启动(不需要)并打开下载的.WHL文件的当前目录,并将其保存在您的PC中python/ anaconda端子/ cmd:

例如:

c:\ users \ user-&gt; cd桌面
“如果将文件下载到桌面”
此命令将使您转移到.WHL文件的当前目录

然后输入:
“ pip install dlib-122.99-cp39-cp39-win_amd64.whl”

应该有效

download cmake executable file on your pc, install it and install cmake build tools for c++ from visual studio build tools. After installing cmake with visual studio build tools, you need to download dlib wheel file from this github repo: https://github.com/Tobyyosoba777/Computer-Vision-OpenCv-Python-/tree/main/Libraries

download:
dlib-19.22.99-cp39-cp39-win_amd64.whl

and download:
dlib-19.22.99.win-amd64-py3.9.exe

install the .exe file on your pc, restart it(not necessary) and open the current directory of the downloaded .whl file where it is saved on your pc in your python/anaconda terminal/ cmd

for example:

C:\Users\USER->cd desktop
"if you downloaded the file to your desktop"
this command will move you to the current directory of the .whl file

then input:
"pip install dlib-19.22.99-cp39-cp39-win_amd64.whl"

that should work

黄昏下泛黄的笔记 2025-01-26 16:15:40

dlib 文档说:

我们还应该特别注意与使用Visual Studio使用预编译的C ++库有关的问题。 TLDR是,除非您真的知道自己在做什么,否则不应将预编译的库(即.lib文件)使用。这不是DLIB的限制。它与Dlib无关。这就是Visual Studio的工作方式。请不要问我。如果您想了解这一点,则应阅读Visual Studio文档,尤其是如此出色的概述。

有了那个蜜蜂,他们很可能不会与安装程序一起运送预先编译的库,并且为了在Windows上使用它,您必须自己编译它,并且要编译它,您需要Visual Studio(Mingw或Clang或Clang不会工作)。

如果您不介意在系统中安装另一个Python实例,则可以使用Conda进行预编译DLIB。

Dlib documentation says:

We should also make a special note of the problems associated with using precompiled C++ libraries with Visual Studio. The TLDR is that you should not use precompiled libraries (i.e. .lib files) with Visual Studio unless you really know what you are doing. This is not a dlib limitation. It has nothing to do with dlib. It's just how Visual Studio works. Please do not ask me about it. If you want to understand this you should read the Visual Studio documentation and this excellent overview in particular.

With that beeing said, it's likely they don't ship precompiled library with their installers, and it order to use it on windows you have to compile it yourself, and to compile it you need Visual Studio (mingw or clang wont work).

If you dont mind installing another instance of python in your system, you can use conda to get precompiled dlib.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文