简体   繁体   English

import dlib ImportError:Ubuntu 18.04 中没有名为 dlib 的模块

[英]import dlib ImportError: No module named dlib in Ubuntu 18.04

I am using.php file and calling one python file though Symfony Components which contains dlib and cv2.我正在使用.php 文件并通过包含 dlib 和 cv2 的 Symfony 组件调用一个 python 文件。 This python file works fine in terminal but calling from php file.这个 python 文件在终端中工作正常,但从 php 文件调用。 It give an error.它给出了一个错误。

Code代码

$process = Process::fromShellCommandline('python /home/machine/openface/demos/compare_two_pic.py {/home/machine/openface/demos/images/orange.jpg,/home/machine/openface/demos/images/orange.jpg}');

$process->run();

echo "here".$process->getOutput();

// executes after the command finishes
        if (!$process->isSuccessful()) {
            throw new ProcessFailedException($process);
        }

        echo $process->getOutput();

Error Output:错误 Output:

Traceback (most recent call last):回溯(最近一次通话最后):

File "/home/machine/openface/demos/compare_two_pic.py", 
line 12, in <module>
import dlib
ImportError: No module named dlib

In order to install dlib for python3 it's better to use pip:为了为 python3 安装 dlib,最好使用 pip:

pip install dlib

You will need boost python.您将需要升压 python。 To get it:为拿到它,为实现它:

sudo apt-get install libboost-all-dev

If you have "Could NOT find PythonLibs (missing: PYTHON_LIBRARIES) (Required is at least version "3.4")" error make sure you have cmake > 2.8 (In my case it is 3.2.2).如果您有“找不到 PythonLibs(缺少:PYTHON_LIBRARIES)(至少需要版本“3.4”)”错误,请确保您的 cmake > 2.8(在我的情况下是 3.2.2)。 To install cmake > 2.8:要安装 cmake > 2.8:

sudo add-apt-repository ppa:george-edison55/cmake-3.x
sudo apt-get update
sudo apt-get install cmake

That solved the issue for me.这为我解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM