In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Today, I will talk to you about how to use Sublime Text 3 and its plug-ins to create a Python integrated development environment under Ubuntu, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.
Author: bit group
Machine Learning and Mathematics production
The previous article talked about the algorithm libraries related to machine learning, all of which are related to the python language, so this article is devoted to using Sublime Text 3 and its plug-ins under ubuntu to create an python integrated development environment. Why choose Sublime Text 3, good appearance is naturally a big factor, but with some plug-ins it does become very powerful, that is, good-looking and can do how to miss it.
one
Install Sublime Text 3
Go to the official website https://www.sublimetext.com/3 to download the latest version, and then search the key, you know.
two
Install plug-in management tools
First install a plug-in management tool to facilitate the installation and removal of plug-ins. Press ctrl+ `or menu View | Show Console to open the console console, and enter
Import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + 8bc59f460fa1548d1514676163dafc88; pf =' Package Control.sublime-package'; ipp = sublime.installed_packages_path (); urllib.request. Install_opener (urllib.request.build_opener (urllib.request.ProxyHandler (); by = urllib.request.urlopen ('http://packagecontrol.io/' + pf.replace ('','% 20')) .read (); dh = hashlib.sha256 (by) .hexdigest () Print ('Error validating download (got% s instead of% s), please try manual install'% (dh, h)) if dh! = h else open (os.path.join (ipp, pf),' wb') .write (by)
You can then use the menu Preferences | Package Control to enable the Sublime Text 3 plug-in management tool:
The shortcut key for the Install Package command is: Ctrl+Shift+P, then select Install Package, enter the name of the plug-in you want to install and click to install it. The plug-ins for Sublime Text 3 are placed in the following directory, one for each plug-in: ~ / .config / sublime-text-3/Packages. The user customization documents for all plug-ins (* .sublime-settings) are placed in the directory ~ / .config / sublime-text-3/Packages/User.
three
Important plug-ins and their settings
1 、 SublimeREPL
SublimeREPL provides a runtime environment that executes many scripting languages. Click Preferences | Package Control | Package Control: Install Package in the menu bar, type SublimeREPL, and press enter to install. Once installed, you can use menu items to get SublimeREPL to run the program.
In this way, press ctrl+r in the python file, and the running window can be displayed when you open the double screen. Here I set the shortcut key of the mode to ctrl+\ (transfer character'\'). You can choose the key that you find convenient. Press the shortcut key ctrl+\ under the python file to start the pdb mode, as shown in the following two pictures
You can search for web articles, such as http://www.cnblogs.com/xianwang/p/4916045.html, by using pdb to debug python programs.
If you use virualenv, you'll probably want to avoid using the system's python, so you need to specify the path to the python. To keep it simple, you can specify ~ / .config / sublime-text-3/Packages/SublimeREPL/config/Python/Main.sublime-menu in the following file.
2 、 SideBarEnhancements
Provides the right-click selection function of the sidebar (SideBar) (press Ctrl+K+B to show / hide the sidebar)
3 、 Anaconda
The Anaconda we are talking about here is not the python scientific computing integration package, but the plug-in of Sublime Text 3, which makes it a killer of IDE. It provides automatic completion and syntax prompt plug-ins, and provides "jump to definition", "find and use", "display documents", "automatic renaming" and other plug-ins in IDE functions. You can install it through Package Control, or you can track the latest version using Git.
1) automatic input of function parameters
If there is in the user settings document, set complete_parameters to true, add the left parenthesis to the input function name (which will automatically display the parameters of the function), you can also set complete_all_parameters to true.
2) when entering keywords such as import def, the Python Package preset by Sublime itself cancels AutoComplete, so when it is like import module, it does not display a float box for automatic completion. You can do this by downloading the file https://raw.githubusercontent.com/DamnWidget/anaconda/master/Completion%20Rules.tmPreferences and putting it in the ~ / .config/sublime-text-3/Packages/ Python directory.
If it is not annoying, it can also be displayed automatically when typing, which requires creating a Python.sublime-settings file in the Packages/User directory and adding the following
{
"auto_complete_triggers": [{"selector": "source. Python-string-comment-constant.numeric", "characters": "."}]
}
4. Enable and use the set python from the virtualenv environment
Set the python_interpreter entry in the file ~ / .config / sublime-text-3/Packages/User/Anaconda.sublime-settings as follows
/ * Default python interpreter.
This can (and should) be overridden by project settings * /
"python_interpreter": "$VIRTUAL_ENV/bin/python"
Then you should start Sublime Text from the virtual environment of the terminal at this time, and the command is subl. Note, however, that this setting is replaced by the setting in the project file (if any). The command is as follows
(python2.7) tensor@tensor-com:~$ subl
four
Engineering setup
Because python can set up different virtual environments through virtualenv and develop different projects in different environments to achieve the advantage of independent environment and non-interference with each other, we hope that different virtual environments can be automatically selected when using Sublime development.
1) add the directory to the project, use the menu Project | Add Folder to Project or drag the directory directly to the sublime
2) Save the current document as a project. Click Save from the menu Project | Save Project As, and two files will be generated in the selected directory:
Project_name.sumlime-project: contains the project definition, which will be recorded in version control
Project_name.sublim-workspace: contains the user's engineering data, such as open files and changes, which will not be recorded in version control.
3) if you have several projects to develop at the same time, you can open the projects you need to work in the following two ways:
Start Sublime Text, click Project > Open Project, find the * .sublime-project file, and open it.
Start Sublime Text, use the Ctrl + Alt + P shortcut key, and you will get a search box that lists all open project names, select the project and open it.
4) you can specify virtualenv in the project settings, so you can set the corresponding sublime.project as follows:
{
...
"settings":
{
"python_interpreter": "~ / env/python2.7/bin/python"
}
}
five
Common shortcut keys
Comments, that is, add #: ctrl+/
Copy rows or selections: ctrl+shift+d
Cut rows or selected items: ctrl + x
Move the whole line up and down: ctrl + shift + ↑ or ctrl + shift + ↓
Delete a line: ctrl+shift + k
Increase and decrease indentation: ctrl + [or]
Select the same item nearby: ctrl+d (place the cursor over a word, press ctrl+d, and the word will be selected. Hold down ctrl and press D multiple times to select the next match of the currently selected item. By holding down ctrl and pressing D three times, three identical texts will be selected. )
Select the content in parentheses: ctrl + shift + m
Quick search: ctrl + P (enter the @ + function name to quickly find the function; enter # + text to quickly match the text within the file. )
Quickly jump to a line: Ctrl + G, enter the line number, you can quickly jump to the line.
Quickly add a new line: Ctrl + Enter can create a new row under the current line; Ctrl + Shift + Enter can add a row above the current line.
After reading the above, do you have any further understanding of how to use Sublime Text 3 and its plug-ins to build a Python integrated development environment under Ubuntu? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.