linux环境下python机器学习环境的搭建
  TEZNKK3IfmPf 2023年11月12日 26 0

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

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

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月12日 0

暂无评论

推荐阅读
TEZNKK3IfmPf