1.Anaconda
从官网下载sh安装包后通过Xftp上传到服务器,通过
root@jamesmartins:~# bash Anaconda2-4.3.1-Linux-x86_64.sh
安装完后记得添加路径,默认是不选,所以一定要选呀。Do you wish the installer to prepend the Anaconda2 install location
to PATH in your /home/gjq/.bashrc ? [yes|no]
[no] >>> yes
让.bashrc生效:
root@jamesmartins:~# source ~/.bashrc
测试python环境是否安装好:
root@jamesmartins:~# python
参考博客:http://blog.csdn.net/gjq246/article/details/70848831
2. 安装opencv
从anaconda官网的库下载opencv3
root@jamesmartins:~# conda install --channel https://conda.anaconda.org/menpo opencv3
安装好后,进入python环境,导入cv2库,报错
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory
搜索这个包在哪里
root@jamesmartins:~# apt install apt-file
root@jamesmartins:~# apt-file update //更新文件库
root@jamesmartins:~# apt-file search libgtk-x11-2.0
root@jamesmartins:~# apt-get install libgtk2.0-0
再到python环境下进行测试,成功
root@jamesmartins:~# import cv2
3.安装dlib
添加源:
root@jamesmartins:~# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
root@jamesmartins:~# conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
root@jamesmartins:~# conda config --add channels https://anaconda.org/menpo/
root@jamesmartins:~# conda config --set show_channel_urls yes
安装cmake用来编译dlib:
root@jamesmartins:~# apt-get install cmake
使用pip安装dlib:
root@jamesmartins:~# pip install dlib
然后等电脑自身编译出whl文件进行安装
进入python环境进行测试:
root@jamesmartins:~# python
Python 3.6.3 |Anaconda custom (64-bit)| (default, Oct 13 2017, 12:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dlib
>>>
4.使用人脸预测程序验证python环境是否配置成功
root@jamesmartins:/home/face_rating# python main.py
Please input image name(like 2.jpg):1.jpg
1 faces detected.
1.jpg, get!
Save features successful!
[ 3.522]
Index 0: 3.5220
可以通过访问 Github获取源代码:https://github.com/wushichatong/face_rating