您的位置:首页 > 编程语言 > Python开发

Ubuntu 16.04下 配置python开发环境

2018-02-09 11:34 465 查看

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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息