Python 在 Windows 10 上安装 dlib

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41912372/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 01:50:39  来源:igfitidea点击:

dlib installation on Windows 10

pythonimage-processingdlib

提问by Drill

I want to use dlibwith python for image recognition. I have the python app running great with OpenCV on Windows 10, but when I want to install dlibfrom the cmdit gives me this following error :

我想dlib用 python 进行图像识别。我在 Windows 10 上使用 OpenCV 运行了很好的 python 应用程序,但是当我想dlibcmd它安装时,它给了我以下错误:

error: Cannot find cmake, ensure it is installed and in the path. You
can install cmake using the instructions at https://cmake.org/install/
You can also specify its path with --cmake parameter.

What should I do?

我该怎么办?

My command prompt error

我的命令提示符错误

回答by Marco D.G.

Install Dlib from .whl

从 .whl 安装 Dlib

Dlib 19.7.0

Dlib 19.7.0

pip install https://pypi.python.org/packages/da/06/bd3e241c4eb0a662914b3b4875fc52dd176a9db0d4a2c915ac2ad8800e9e/dlib-19.7.0-cp36-cp36m-win_amd64.whl#md5=b7330a5b2d46420343fbed5df69e6a3f

You can test it, downloading an example from the site, for example SVM_Binary_Classifier.pyand running it on your machine.

您可以测试它,从站点下载示例,例如SVM_Binary_Classifier.py并在您的机器上运行它。

Note: if this message occurs you have to build dlib from source:

注意:如果出现此消息,您必须从源代码构建 dlib

dlib-19.7.0-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform

dlib-19.7.0-cp36-cp36m-win_amd64.whl 在此平台上不受支持



Install Dlib from source (If the solution above doesn't work)

从源代码安装 Dlib(如果上面的解决方案不起作用)

WindowsDlib > 19.7.0

WindowsDlib > 19.7.0

  1. Download the CMake installer and install it: https://cmake.org/download/
  2. Add CMake executable path to the Enviroment Variables:

    set PATH="%PATH%;C:\Program Files\CMake\bin"

    note: The path of the executable could be different from C:\Program Files\CMake\bin, just set the PATH accordingly.

    note: The path will be set temporarily, to make the change permanent you have to set it in the “Advanced system settings” → “Environment Variables”tab.

  3. Restart The Cmd or PowerShell window for changes to take effect.

  4. Download the Dlib source(.tar.gz) from the Python Package Index : https://pypi.org/project/dlib/#filesextract it and enter into the folder.
  5. Check the Python version: python -V. This is my output: Python 3.7.2so I'm installing it for Python3.x and notfor Python2.x

    note: You can install it for both Python 2 and Python 3, if you have set different variables for different binaries i.e: python2 -V, python3 -V

  6. Run the installation: python setup.py install

  1. 下载 CMake 安装程序并安装:https: //cmake.org/download/
  2. 将 CMake 可执行路径添加到环境变量:

    set PATH="%PATH%;C:\Program Files\CMake\bin"

    注意:可执行文件的路径可能与 不同C:\Program Files\CMake\bin,只需相应地设置 PATH。

    注意:路径将是临时设置的,要使更改永久生效,您必须在“高级系统设置”→“环境变量”选项卡中进行设置。

  3. 重新启动 Cmd 或 PowerShell 窗口以使更改生效。

  4. 从 Python Package Index 下载 Dlib 源(.tar.gz):https://pypi.org/project/dlib/#files解压并进入文件夹。
  5. 检查 Python 版本:python -V. 这是我的输出:Python 3.7.2所以我为 Python3.x 而不是Python2.x安装它

    :您可以安装两个Python 2和Python 3中,如果您已经为不同的二进制文件不同的变量,即:python2 -Vpython3 -V

  6. 运行安装: python setup.py install



LinuxDlib 19.17.0

LinuxDlib 19.17.0

sudo apt-get install cmake

wget https://files.pythonhosted.org/packages/05/57/e8a8caa3c89a27f80bc78da39c423e2553f482a3705adc619176a3a24b36/dlib-19.17.0.tar.gz

tar -xvzf dlib-19.17.0.tar.gz

cd dlib-19.17.0/

sudo python3 setup.py install

note: To install Dlib for Python 2.x use pythoninstead of python3you can check your python version via python -V

注意:要安装 Dlib for Python 2.x 使用python而不是python3您可以通过以下方式检查您的 python 版本python -V

回答by Rajat Bhatt

Follow these steps:

按着这些次序:

  • pip install cmake
  • Install Visual Studio build tools from here.
  • In Visual Studio 2017 go to the Individual Components tab, Visual C++ Tools for Cmake, and check the checkbox under the "Compilers, build tools and runtimes" section.
  • pip install dlib
  • pip install cmake
  • 这里安装 Visual Studio 构建工具。
  • 在 Visual Studio 2017 中,转到单个组件选项卡、Visual C++ Tools for Cmake,然后选中“编译器、构建工具和运行时”部分下的复选框。
  • pip install dlib

回答by PINK

You need to install Cmake.

您需要安装Cmake

dlib is an c++ libary with python bindings. It needs to be builded first. My guess is this will happen automatically once you have installed Cmake

dlib 是一个带有 python 绑定的 C++ 库。它需要首先构建。我猜这会在你安装 Cmake 后自动发生

回答by Dedalo

You have to install cmake as the error tells you.

您必须按照错误提示安装 cmake。

you can follow this instructions https://www.learnopencv.com/install-dlib-on-windows/

您可以按照此说明https://www.learnopencv.com/install-dlib-on-windows/

or directly install cmake from here https://cmake.org/download/

或直接从这里安装 cmake https://cmake.org/download/

Once cmake is installed pip install dlib should work.

安装 cmake 后, pip install dlib 应该可以工作。

I had vstudio building tools installed whe I did my test.

我在测试时安装了 vstudio 构建工具。

回答by Ramisha Rani K

Choose dlib .whl file according to your installed python version. For example if installed python version is 3.6.7 , 64bit system or if python is 3.5.0 32 bit then choose dlib-19.5.1-cp36-cp36m-win_amd64.whl and dlib-18.17.100-cp35-none-win32.whl respectively.

根据您安装的python版本选择dlib .whl文件。例如,如果安装Python版本是3.6.7,64位的系统,或者是蟒然后3.5.0 32位选择DLIB-19.5.1- CP36-cp36m-win_ AMD64.whl和DLIB-18.17.100- CP35无-无的win32.whl 分别。

Bolded text says the python supporting version.

粗体文字表示 python 支持版本。

Download wheel file from hereor copy the link address

这里下载wheel文件或复制链接地址

pip install dlib-19.5.1-cp36-cp36m-win_amd64.whl

for above method .whl file shoud be in the working directory

对于上述方法 .whl 文件应该在工作目录中

or

或者

Below link for python3.6 supporting dlib link, for python 3.5 u can replace with dlib 35.whl link

下面的python3.6支持dlib链接的链接,对于python 3.5你可以用dlib 35.whl链接替换

pip install https://files.pythonhosted.org/packages/24/ea/81e4fc5b978277899b1c1a63ff358f1f645f9369e59d9b5d9cc1d57c007c/dlib-19.5.1-cp36-cp36m-win_amd64.whl#sha256=7739535b76eb40cbcf49ba98d894894d06ee0b6e8f18a25fef2ab302fd5401c7

回答by barnwaldo

Just a quick update on what has worked for me (two years later). Davis King has provided two ways to add the latest python dlib (19.17.0) to any python environment in Windows 10 for me. Note, I run several Linux configs in Oracle VirtualBox but Windows 10 is my native OS which has access to the Nvidia GPU so i need an install on Windows 10. (Cannot access the GPU - easily - through VirtualBox).

只是快速更新对我有用的东西(两年后)。Davis King 为我提供了两种将最新的 python dlib (19.17.0) 添加到 Windows 10 中的任何 python 环境的方法。请注意,我在 Oracle VirtualBox 中运行了多个 Linux 配置,但 Windows 10 是我的本机操作系统,它可以访问 Nvidia GPU,因此我需要在 Windows 10 上进行安装。(无法通过 VirtualBox 轻松访问 GPU)。

First - the easiest:

首先 - 最简单的:

pip install dlib

and the website link: https://pypi.org/project/dlib/

和网站链接:https: //pypi.org/project/dlib/

And then it can be easily be build from sources. Download from https://pypi.org/simple/dlib/and follow instructions on http://dlib.net/compile.html.

然后它可以很容易地从源代码构建。从https://pypi.org/simple/dlib/下载并按照http://dlib.net/compile.html 上的说明进行操作。

Also, just found another way to access with Visual Studio 2019 (or 2017). Use vcpkg - see link https://vcpkg.readthedocs.io/en/latest/

另外,刚刚找到了另一种使用 Visual Studio 2019(或 2017)访问的方法。使用 vcpkg - 请参阅链接https://vcpkg.readthedocs.io/en/latest/

I built dlib 19.17 on Windows 10 with CMake and it worked fine but then I found vcpkg and now the dlib libraries are integral to the Visual Studio. I no longer need to add all the external links to C++ and the linker.The version in vcpkg is currently 19.16-1 and it is built with full CUDA support.

我使用 CMake 在 Windows 10 上构建了 dlib 19.17,它运行良好,但后来我发现了 vcpkg,现在 dlib 库是 Visual Studio 不可或缺的一部分。我不再需要将所有外部链接添加到 C++ 和链接器。 vcpkg 中的版本目前是 19.16-1,它是完全支持 CUDA 的。

Hope this helps others..

希望这对其他人有帮助..

回答by Symyon

You can use vcpkgto install dlib.

您可以使用vcpkg安装dlib

If you don't have vcpkg, you can get it here(Read Quick Start)

如果您没有vcpkg,可以在此处获取(阅读快速入门)

After you got vcpkg, run:

获得 vcpkg 后,运行:

vcpkg install dlib:x64-windows

回答by Vinay Chaudhari

Simple and 100% working trick

简单且 100% 的工作技巧

(Make sure you install cmake)

(确保你安装了 cmake)

My Anaconda python ver : 3.6.8 (64 bit) | OS :Windows 10

我的 Anaconda python 版本:3.6.8(64 位)| 操作系统:Windows 10

python -m pip install https://files.pythonhosted.org/packages/0e/ce/f8a3cff33ac03a8219768f0694c5d703c8e037e6aba2e865f9bae22ed63c/dlib-19.8.1-cp36-cp36m-win_amd64.whl#sha256=794994fa2c54e7776659fddb148363a5556468a6d5d46be8dad311722d54bfcf

enter image description here

enter image description here

回答by Talha Anwar

I have recently installed dlib on python 3.7. First I have installed cmake from anaconda navigator (cmake version 3.14.0)Next i installed visual studio 2019 and installed Desktop development with C++. Then I do pip install dliband now its working

我最近在 python 3.7 上安装了 dlib。首先,我从 anaconda navigator 安装了 cmake(cmake version 3.14.0)接下来我安装了 Visual Studio 2019 并使用 C++安装了桌面开发。然后我做pip install dlib,现在它的工作

回答by Chandan Purohit

None of the answers worked for me. This is what worked Assuming you have anaconda python 3.7 installed

没有一个答案对我有用。假设您安装了 anaconda python 3.7,这就是有效的

1) Dowload and install cmake(make sure to check the option to add cmake to system path during installation to avoid manually doing later) Download from this link cmake download

1)下载并安装cmake(安装时一定要勾选将cmake添加到系统路径的选项,以免以后手动操作)从这个链接下载cmake下载

2) conda install -c conda-forge dlib

2) conda install -c conda-forge dlib