Home  >  Article  >  Backend Development  >  Ubuntu16.04 sets python3 as the default and installs some libraries

Ubuntu16.04 sets python3 as the default and installs some libraries

巴扎黑
巴扎黑Original
2017-06-23 14:47:462190browse

Ubuntu’s default Python is 2.7, so when installing the Python package, the py2 package is installed.

Use the alternatives mechanism to change py3 to default.

Execute in shell:

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

The effect is as follows:

At this time, enter the installation command on the command terminal The package that supports py3 will be automatically installed.

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

Statistical modeling analysis tool statsModels:

sudo apt-get install python-statsmodels

Machine learning library scikit-learn:

sudo apt-get install python-sklearn

xgboost:

sudo -H pip install --pre xgboost

seaborn, a drawing tool, is a supplement to matplotlib, making more attractive pictures:

sudo pip install seaborn

If you want to switch to Python2, execute:

sudo update-alternatives --config python

Follow the prompts and enter the selected number and press Enter. Executing the above command under py2 will install the installation package corresponding to py2, and the system will automatically choose to download it.

The above is the detailed content of Ubuntu16.04 sets python3 as the default and installs some libraries. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn