Ubuntu安装Python机器学习包

1.安装pip

$ mkdir ~/.pip

$ vi ~/.pip/pip.conf

[global]

trusted-host=mirrors.aliyun.com

index-url=http://mirrors.aliyun.com/pypi/simple/ 

$ wget
https://bootstrap.pypa.io/get-pip.py $ sudo python get-pip.py $ pip --version pip 9.0.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)

2.安装机器学习包

下面安装包由于有依赖关系,顺序不能混乱

$ sudo pip install numpy

$ sudo pip install pandas

$ sudo pip install patsy

$ sudo pip install scipy

报错:

statsmodels/tsa/kalmanf/kalman_loglike.c:8:22: fatal error: pyconfig.h: No such file or directory

compilation terminated.

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

执行命令安装g++

$ sudo apt-get install g++


$ sudo apt-get install python-dev

由于天朝的网安装python-dev太慢,所以我对ubuntu更新成国内源。用命令行的形式直接替换/etc/apt/source.list(替换前先备份)文件中的内容,但在sudo apt-get update的时候报各种错,最后选择了另一种方法。

lh@ubuntu:~/.pip$ lsb_release -a

No LSB modules are available.

Distributor ID: Ubuntu

Description: Ubuntu 16.04.1 LTS

Release: 16.04

Codename: xenial

直接在图形化界面中system settings中点software&updates中选择

安装python-dev报错:

解决方法:

 

$ sudo apt-get install aptitude
$ sudo aptitude install python-dev

 

第二个选择n,y,y。

$ sudo pip install statsmodels
$ sudo pip install scikit-learn
$ sudo pip install matplotlib

Succeed!

 

posted @ 2017-01-15 14:54  派。  阅读(1434)  评论(0编辑  收藏  举报