linux环境下python机器学习环境的搭建##
1、准备工作,查看linux自带的python版本,以及建立一个测试目录用于存放测试文件:
ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb/tuijian/testpython$ python -V
Python 2.7.12
ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb/tuijian$ sudo mkdir testpython
ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb/tuijian$ cd testpython/
ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb/tuijian/testpython$ vi test.py
#!/usr/bin/env python
print 'Hello,Welcome to linux python'
如果小于python2.7.需要安装成pthon2.7.,保存之后,使用如下运行:
ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb/tuijian/testpython$ python test.py
Hello,Welcome to linux python
运行成功
2、安装机器学习所需要的库:
sudo apt-get update
sudo apt-get install python-numpy
sudo apt-get install python-scipy
sudo apt-get install python-matplotlib
sudo apt-get install python-pandas
sudo apt-get install python-sklearn
安装完成之后,
ubuntu@VM-164-254-ubuntu:/var/www/html/test/adminweb/tuijian/testpython$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
/usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> import pandas as pd
>>> from sklearn import datasets,linear_model
>>> exit()
当:
>>> import matplotlib.pyplot as plt
/usr/lib/python2.7/dist-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
这里不是异常,等待一段时间就可以了。至此,安装完成。