ubuntu17 设置python3为默认及一些库的安装

ubuntu17 设置python3为默认及一些库的安装

Ubuntu默认Python为2.7,所以安装Python包时安装的为py2的包。

利用alternatives机制更改py3为默认。

shell里执行:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 100
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 150

效果如下:

此时,在命令端输入安装命令则会自动安装支持py3的包。

Numpy:

sudo apt-get install python-numpy

Scipy:

sudo apt-get install python-scipy

Matplotlib:

sudo apt-get install python-matplotlib

Pandas:

sudo apt-get install python-pandas

统计建模分析工具statsModels:

sudo apt-get install python-statsmodels

机器学习库scikit-learn:

sudo apt-get install python-sklearn

xgboost:

sudo -H pip install --pre xgboost

 seaborn,作图工具,是matplotlib的补充,制作更具吸引力的图:

sudo pip install seaborn

如果要切换到Python2,执行:

sudo update-alternatives --config python

按照提示输入选择数字回车即可。在py2下执行以上命令安装的是py2对应的安装包,系统会自动选择下载。

愿你保持清醒而时光无可虚度、
原文地址:https://www.cnblogs.com/yisawatbek/p/7998651.html