Ubuntu 16.04下 配置python开发环境

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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值