Configure the Sublime Text3 --- python environment and ubantulamp environment in Ubantu

Source: Internet
Author: User
Tags install matplotlib

Configure the Sublime Text3 --- python environment and ubantulamp environment in Ubantu

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:
  1. Sudo add-apt-repository ppa: webupd8team/sublime-text-3
  2. Sudo apt-get update
  3. 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:

 
  1. Sudo apt-get install python-numpy
  2. Sudo apt-get install python-scipy

2. Install the above two packages, and then install matplotlib:

 
  1. Sudo apt-get python-matplotlib

3. After installation, test the environment, that is, python + numpy + matplotlib.

 
  1. Import matplotlib. pyplot as plt
  2. Import numpy as np
  3. # To draw y = x ^ 2 (-3 <= x <= 3)
  4. X = np. arange (-3, 3.5, 0.5)
  5. Y = [ele ** 2 for ele in x]
  6. Z = [ele * 2 for ele in x]
  7. Fig = plt. figure (1)
  8. Ax = fig. add_subplot (211)
  9. Line1 = ax. plot (x, y, 'ro -')
  10. Ax = fig. add_subplot (212)
  11. Line2 = ax. plot (x, z, 'g -')
  12. Plt. show ()
The above code is entered in sublime, and then press ctrl + B to run:

 

 

The following figure shows the result:

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.