在 Windows 10 上安装 dlib [英] dlib installation on Windows 10

查看:65
本文介绍了在 Windows 10 上安装 dlib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 dlib 和 python 进行图像识别.我的 python 应用程序在 Windows 10 上与 OpenCV 一起运行得很好,但是当我想从 cmd 安装 dlib 时,它给了我以下错误:

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

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.

我该怎么办?

推荐答案

从 .whl 安装 Dlib

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

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

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

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

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

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

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


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

Windows Dlib >19.7.0

  1. 下载 CMake 安装程序并安装它:https://cmake.org/download/

将 CMake 可执行路径添加到环境变量:

Add CMake executable path to the Enviroment Variables:

set PATH=%PATH%;C:Program FilesCMakein"

注意:可执行文件的路径可能与C:Program FilesCMakein不同,只需相应地设置PATH即可.

note: The path of the executable could be different from C:Program FilesCMakein, 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.

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

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

从 Python Package Index 下载 Dlib 源代码(.tar.gz):https://pypi.org/project/dlib/#files 解压并进入文件夹.

Download the Dlib source(.tar.gz) from the Python Package Index : https://pypi.org/project/dlib/#files extract it and enter into the folder.

检查 Python 版本:python -V.这是我的输出:Python 3.7.2 所以我为 Python3.x 安装它,为 Python2.x

Check the Python version: python -V. This is my output: Python 3.7.2 so I'm installing it for Python3.x and not for Python2.x

注意:如果你为不同的二进制文件设置了不同的变量,你可以为 Python 2 和 Python 3 安装它:python2 -V, python3-V

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 步之前,请确保以管理员身份打开 PowerShell,并且您位于 dlib 目录中

NOTE: Make sure to open the PowerShell as admin, and you're inside the dlib directory before proceeding to step 6

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


Linux Dlib 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

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

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

这篇关于在 Windows 10 上安装 dlib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆