zoukankan      html  css  js  c++  java
  • Centos7+python3.6+face-recognition

    Step1

    安装Python3.6.x
    https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-centos-7

    sudo yum -y update

    sudo yum -y install yum-utils

    sudo yum -y groupinstall development

    sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm

    sudo yum -y install python36u

    接下来就可以用python3.6 -V 看一下装成功了没。

    Step2

    安装OpenBLAS
    这个 搜索一下,找个tar包,解压一下。make && make install 即可。很顺利

    Step3

    安装一些依赖包
    sudo yum -y install boost-devel

    Step4 给py3装上face-recognition

    pip3.6 install face-recognition
    推荐使用pip清华源 速度杠杠的
    pip3.6 install face-recognition -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

    华丽丽的坑,就来啦~~

    坑1

    dlib需要OpenBLAS依赖。如果你按照我的步骤来了,那么恭喜你,你不会碰到。(碰到了就来打我)

    坑2

    在安装face-recognition的时候,dlib安装耗时真的很长。当你等完这段时间以后(很开心有木有!)
    在python shell里输入:

    >>> import face-recognition

    .....

    .....

    .....

    .....

    ImportError: ........./python3.6/site-packages/dlib/dlib.so: undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE

     

    这个错误的描述,当时看到,心就凉了半截。多年爬坑经验告所我,谷歌也救不了我。

    果然,我的判断没有错。花了半小时在谷歌各种搜索,没有得到任何答案。
    只有两个感觉:
    1、为啥大家都只有ubuntu的教程!!!!
    2、py3怎么了!!!说好的淘汰py2呢!!!

    不过,作为一个优雅的虔诚的爬坑者,我们遇到这种事一定要优雅~
    反复安装了 18.100 和 19.x.x的多个dlib版本无果后,我不禁思考起了人生。

    ---------------一天后---------------

    不过,天无绝人之路。
    当你静下心来看这段话:

    undefined symbol: _ZN5boost6python6detail11init_moduleER11PyModuleDefPFvvE

    好像并不是乱码诶

    关键字:boost python detail init_module ModuleDef

    运行了如下命令后
    ldd /project/face/lib64/python3.6/site-packages/dlib/dlib.so | grep boost
    我们可以认为,其实有可能是Step3 安装的lib_boost对应的是python2的版本(centos 默认安装python2 有很多系统级应用需要,比如yum)
    说干就干,我们去找个lib_boost的源码包还不容易么。
    解压后,按如下步骤安装(使用lib_boost版本1.5.3)

    1、确认python 安装路径
    whereis python

     

    image.png

    2、cd boost_1_53_0
    ./bootstrap.sh --with-python=/usr/bin/python --with-python-version=3.6 --with-python-root=/usr/lib/python3.6
    sudo ./b2 --enable-unicode=ucs4 install
    等待安装完成后,我满怀信心的:

    import face-recognition

    没有成功!!!相同的报错!!!
    OH!!!NO!!!

    我不信邪,我重新运行了一遍sudo ./b2 --enable-unicode=ucs4 install
    我发现,控制台输出了一堆'fatal error: pyconfig.h: No such file or directory'
    实际上,编译根本没有成功!
    实际上只要添加:
    export CPLUS_INCLUDE_PATH=/usr/include/python3.6m (include路径下的)
    再次运行sudo ./b2 --enable-unicode=ucs4 install
    就没有问题啦~~



    作者:一二三亖19930408
    链接:https://www.jianshu.com/p/1e6ac3d614e3
    來源:简书
    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

     

     

    本博文转自:https://www.jianshu.com/p/1e6ac3d614e3

  • 相关阅读:
    [leetcode]34.Find First and Last Position of Element in Sorted Array找区间
    [leetcode]278. First Bad Version首个坏版本
    [leetcode]367. Valid Perfect Square验证完全平方数
    [leetcode]45. Jump Game II青蛙跳(跳到终点最小步数)
    [leetcode]55. Jump Game青蛙跳(能否跳到终点)
    [leetcode]26. Remove Duplicates from Sorted Array有序数组去重(单个元素只出现一次)
    [leetcode]27. Remove Element删除元素
    [leetcode]20. Valid Parentheses有效括号序列
    [leetcode]15. 3Sum三数之和
    C#中的局部类型
  • 原文地址:https://www.cnblogs.com/hongyunshui666/p/9427848.html
Copyright © 2011-2022 走看看