返回

linux环境下python机器学习环境的搭建

发布时间:2023-02-09 09:23:00 368
# html# python# linux# ubuntu

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.')

这里不是异常,等待一段时间就可以了。至此,安装完成。

 

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线