Many of the books I bought for machine learning algorithms are developed using the python language. Therefore, I also want to configure the python environment in Linux. Sublime is a very popular editor. It can be used to add many small and useful plug-ins, and can also be configured as an IDE that is commonly used in development languages. Therefore, there are many tutorials for configuring Sublime on the Internet, after reading and studying many tutorials, I decided to use Sublime 3 because it is easy to configure the python development environment.
1. Install sublime text 3
Run the following three commands in Ubantu to install Sunlime:
- Sudo add-apt-repository ppa: webupd8team/sublime-text-3
- Sudo apt-get update
- Sudo apt-get install sublime-text
Now we have installed sublime text3. Then we need to configure sublime. Search to open sublime.
Ii. Configure sublime
First, enter a configuration command in the sublime console to install package control. This plug-in is used to search for and install the plug-in:
To open the sublime console, choose view -----------> show console (or press Ctrl + '(the key on the left of number 1) and enter it in the command line)
Enter the following command:
Import urllib. request, OS; pf = 'package Control. sublime-package '; ipp = sublime. installed_packages_path (); urllib. request. install_opener (urllib. request. build_opener (urllib. request. proxyHandler (); open (OS. path. join (ipp, pf), 'wb '). write (urllib. request. urlopen ('HTTP: // sublime.wbond.net/'+ pf. replace ('', '% 20 ')). read ())
After a while, note that the package control configuration is successful, restart sublime after the configuration is successful, and then have the package control column under the Preferece menu. This indicates that the package is successfully installed, now you can install the required plug-in through package control.
The following describes how to configure the python development environment in sublime:
Configure python in sublime
1. Press ctrl + shift + p to display the package control, and then enter install in the input box: select the first list item, press enter, and wait a moment.
2. Another input box is displayed:
3. Input Anaconda and install Anaconda. Anaconda is definitely one of the most exciting plug-ins after switching to Sublime Text 3. In the era of Sublime Text 2, many plug-ins such as All Autocomplete, SublimeREPL, Pylinter, and PEP8 must be installed to configure an easy-to-use python development environment. Geek makes everything easier. The plug-in author puts these functions together for simplicity. Anaconda integrates PyFlakes, pep8, and McCabe as plug-ins. After installing Anaconda, you can complete a good Python development environment through configuration. 4. After a period of time, the installation will be successful. If Anaconda is configured in Preference ---> Package settings, the installation is successful. Now we can use sublime for programming.
In addition, we also need to install other important python dependencies for matrix calculation and drawing, I .e. numpy and matplotlib. In this case, python
And numpy and matplotlib are equivalent to Matlab.
3. Configure the python Environment
1. First install numpy. Run the following command on the Ubantu terminal:
- Sudo apt-get install python-numpy
- Sudo apt-get install python-scipy
2. Install the above two packages, and then install matplotlib:
- Sudo apt-get python-matplotlib
3. After installation, test the environment, that is, python + numpy + matplotlib.
- Import matplotlib. pyplot as plt
- Import numpy as np
- # To draw y = x ^ 2 (-3 <= x <= 3)
- X = np. arange (-3, 3.5, 0.5)
- Y = [ele ** 2 for ele in x]
- Z = [ele * 2 for ele in x]
- Fig = plt. figure (1)
- Ax = fig. add_subplot (211)
- Line1 = ax. plot (x, y, 'ro -')
- Ax = fig. add_subplot (212)
- Line2 = ax. plot (x, z, 'g -')
- Plt. show ()
The above code is entered in sublime, and then press ctrl + B to run:
The following figure shows the result: