Easy machine learning (Python) environment construction on Ubuntu

Introduction

I don't know what the number is, but I will leave a note when I built a new machine learning (Python) environment on Ubuntu. For those who want to easily build an environment with minimal installation using Python pre-installed on the system (Ubuntu) **. Environment: Ubuntu 20.04 LTS

Install Python, pip, venv

If you have a regular distribution of Ubuntu 20.04 LTS, Python3 should be pre-installed. Just in case, enter the following in the terminal and confirm it.

Terminal


python3 -V               
Python 3.8.2

#If not installed
sudo apt install python3

Next, install pip, which is required to install various libraries.

Terminal


sudo apt install python3-pip

#Confirmation of installation
pip3 --version

Installing the library directly in Python used on your system is not recommended as it can damage your system in the worst case. Therefore, build a virtual environment so that the installation of the library does not affect the system dependency environment. To use venv with Ubuntu pre-installed Python, the following installation is required.

Terminal


sudo apt install python3-venv

Creating and enabling a virtual environment

Create a virtual environment before installing the library.

Terminal


#In your home directory.Create a virtual environment called ML in the venv folder
python3 -m venv .venv/ML

Execute the following to activate the created virtual environment.

Terminal


cd .venv/ML
source bin/activate

#When disabling, do the following
deactivate

Library installation

We will install the library in the virtual environment. The following is an example of installing scikit-learn, matplotlib, and pandas all at once.

Terminal


pip3 install -U scikit-learn ,matplotlib, pandas

UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

This is because Tkinter, which is required for drawing the UI on Python, is not installed. It is good to install it together.

Terminal


sudo apt install python3-tk

This is the end of environment construction.

Postscript

When coding with VS Code, it is convenient to set the virtual environment created earlier as the default interpreter. If you add the following to Settings.json, the virtual environment will be automatically activated and the program will be executed.

Settings.json


"python.defaultInterpreterPath": "/home/$USERNAME/.venv/ML/bin/python3",

Recommended Posts

Easy machine learning (Python) environment construction on Ubuntu
OpenCV3 & Python3 environment construction on Ubuntu
Python and machine learning environment construction (macOS)
Set up python and machine learning libraries on Ubuntu
Python environment construction memo on Mac
Python development environment construction on macOS
Environment construction of python3.8 on mac
Build Python 3.8 + Pipenv environment on Ubuntu 18.04
Environment construction of "Tello_Video" on Ubuntu
Machine learning environment settings based on Python 3 on Mac (coexistence with Python 2)
python environment construction
Python --Environment construction
Python environment construction
Steps to install Python environment on Ubuntu
Created Ubuntu, Python, OpenCV environment on Docker
Environment construction procedure: Ubuntu + Apache2 + Python + Pyramid
EV3 x Pyrhon Machine Learning Part 1 Environment Construction
[0] TensorFlow-GPU environment construction built with Anaconda on Ubuntu
[Venv] Create a python virtual environment on Ubuntu
python2.7 development environment construction
Python 3.x environment construction by Pyenv (CentOS, Ubuntu)
build Python on Ubuntu
Install Python 3.3 on Ubuntu 12.04
Python environment construction @ Win7
Build a Python machine learning environment with a container
Install NVIDIA-driver (GeForce RTX 2070 SUPER), cuda 10.1, cudnn 7.6 on Ubuntu 18.04.3 LTS + python environment construction
I made a Python3 environment on Ubuntu with direnv.
Build a machine learning application development environment with Python
Memo for building a machine learning environment using Python
Build a machine learning environment natively on Windows 10 (x64)
Machine learning with Python! Preparation
Put Python 3.x on Ubuntu
Build python3 environment with ubuntu 16.04
Python environment construction For Mac
Build Python environment on Windows
Python3 environment construction (for beginners)
Python environment construction and TensorFlow
Install OpenCV on Ubuntu + python
Build python environment on windows
Build a machine learning environment
Introducing TensorFlow on Ubuntu + Python 2.7
Python Machine Learning Programming> Keywords
Python environment construction under Windows7 environment
[MEMO] [Development environment construction] Python
Ubuntu14.04 + GPU + TensorFlow environment construction
[Tensorflow] Tensorflow environment construction on Windows 10
Beginning with Python machine learning
Linux environment construction (on WSL environment)
Environment construction of python2 & 3 (OSX)
Until you create a machine learning environment with Python on Windows 7 and run it
Python environment construction procedure memo using Docker on Windows10 Home
Create a virtual environment for python on mac [Very easy]
VScode environment construction (on Mac) & graph display in Python (@browser)
Python environment construction (pyenv, anaconda, tensorflow)
[Python3] Development environment construction << Windows edition >>
Python environment construction (pyenv + poetry + pipx)
Set up Python environment on CentOS
<For beginners> python library <For machine learning>
Create a python environment on centos
[Linux] Docker environment construction on Redhat
Python: Preprocessing in Machine Learning: Overview