I wanted to build an environment for machine learning, but it seems that installing a special library that is used for machine learning as it is may cause the computer to start up strangely and the OS to start up. So, this time, I will introduce a method for building an OS-independent virtual environment to prevent such a situation. This time, we will introduce from the contents of Introduction to Machine Learning for Data Analysis.
The operating environment this time is
It is like this.
First, use pip and enter the following command to install virtualenv.
$ sudo pip install --upgrade virtualenv
After installation, we will actually build a virtual environment with virtualenv. Enter the following command.
$ virtualenv --system-site-packages sample
This will create a directory called "sample". We will build a python execution environment here. If you no longer need it, you can easily uninstall it by deleting the entire directory. Let's take a look at how to specifically activate this virtual environment.
$ cd sample
$ . ./bin/activate
After activating, the terminal display will change as follows.
(sample)$
The virtual environment is now running. To restore it, use the deactive command.
(sample)$ deactivate
Now install the machine learning library scikit-learn in this virtual environment. After activating the virtual environment you built earlier, enter the following command.
(sample)$ pip install -U scikit-learn
You have now installed scikit-learn. From now on, we will create a machine learning program using this scikit-learn.
Recommended Posts