Configure a comfortable Python development environment under Ubuntu

Source: Internet
Author: User

 

Directory (?) [-]

    1. Install Python release and build dependency packages
    2. Installing Pip and Virtualenv
    3. Configure personal use Virtualenv
    4. Installing Git and Gitflow
    5. Installing bash-it
    6. Installing Sublime Text 2
    7. Installing and configuring Vim

Ubuntu provides a good Python development environment, but if we want to maximize our development efficiency, we need to do a lot of customized installation and configuration. Below is an installation and configuration step recommended by our team developer, based on the Ubuntu 12.04 Desktop version Standard installation.

Install Python release and build dependency packages

It is recommended to install at least Python 2.7/3.2 version, after all, Python 2.x/3.x still have a lot of difference.

1234  
# 安装 Python 发布版本,dev包必须安装,很多用pip安装包都需要编译sudo apt-get install python2.7 python2.7-dev python3.2 python3.2-dev# 很多pip安装的包都需要libssl和libevent编译环境sudo apt-get install build-essential libssl-dev libevent-dev libjpeg-dev libxml2-dev libxslt-dev
Installing Pip and Virtualenv

pipis a Python package management tool that suggests that Python packages are managed with PIP. virtualenvPython is a multi-version management of the weapon, different versions of the development of debugging all rely on it.

1234  
# 安装 pipsudo apt-get install python-pip# 安装 virtualenvsudo pip install virtualenv
Configure personal use Virtualenv

Try to install the Python package under Virtualenv.

123)45   
# 安装 python2.7 virtualenvvirtualenv --no-site-packages -p /usr/bin/python2.7 ~/.venv/python2.7# 安装 python3.2 virtualenvvirtualenv --no-site-packages -p /usr/bin/python3.2 ~/.venv/python3.2

Then add the following code to ~/.bashrc the last side, using virtualenv instead of the system Python environment by default:

1234  
# 缺省激活python2.7环境if [ -f ~/.venv/python2.7/bin/activate ]; then . ~/.venv/python2.7/bin/activatefi
Installing Git and Gitflow

gitis the best version management tool to use GitHub Essentials, currently.

1
$ sudo apt-get install git

To configure Git:

123456789        
# commonly used commands are set alias, as little as possible to hit the keyboard git config-- Global alias.br Branchgit config--global alias.ci commitgit config--global alias.co Checkoutgit config--global alias.st status# Very nice show git loggit config--global alias.lg  "log--color--graph--pretty=format: '% Cred%h%creset-%c (yellow)%d%creset%s%cgreen (%CR)%c (bold blue) <%an>%creset '--abbrev-commit--"# set user information git config--global user.name " Your name "git config--global user.email [email protected]# default color display Span class= "line" >git config--global color.ui true       

Installation git-flow , using the standardized git branching process, see:

    • Using Git Flow
    • A successful Git branching model
1
sudo apt-get install git-flow
Installing bash-it

bash-itCan beautify your bash environment, allowing you to use console terminals more efficiently, see bash-it GitHub website for more information

12
git clone http://github.com/revans/bash-it.git ~/.bash_it~/.bash_it/install.sh

When installation can choose all the alias/plugins/completion, if the custom selection, will definitely virtualenv , git plug-in selection.

After the installation is complete, attach the following code to ~/.bashrc the back:

123 
if [ -f ~/.bash_profile ]; then . ~/.bash_profilefi

bash-itAfter installation, the default is to use the Bobby style (see ~/.bash_profile the environment variables defined in BASH_IT_THEME ), edit ~/.bash_it/themes/bobby/bobby.theme.bash , PS1 Add in the definition, ${green}$(virtualenv_prompt) as follows:

1
PS1="\n${yellow}$(ruby_version_prompt)${green}$(virtualenv_prompt) ${purple}\h ${reset_color}in ${green}\w\n${bold_cyan}$(scm_char)${green}$(scm_prompt_info) ${green}→${reset_color} "

Note: Styles define ~/.bash_profile the environment variables defined in the participating Files BASH_IT_THEME , and you also change their values to ~/.bash_it/themes the styles defined elsewhere.

Finally restart the terminal and you will see a different bash , supported display git branch, and virtualenv rvm so on.

Installing Sublime Text 2

In the browser enter Sublime Text 2 official website, select the appropriate version to download the installation.

Installation is also required after Sublime Text 2 the installation is complete Package Control . Installation details see Sublime Packages installation.

Finally, press the shortcut key to bring up the Ctrl+Shift+P command window, select Package Control: Install Package , install Python to develop common plugins:

    • Auto Encoding for Python
    • Brackethighlighter
    • Git
    • Markdown Preview
    • Python Auto-complete
    • Sublimelinter
    • Sidebarenhancements
    • Sublimecondeintel
    • Sublime-github
    • Dayle Rees Color Schemes

Here is a recommended plugin Sublime-github, can be viewed in sublime, add, modify GitHub Gist. If you and your team use Github Gist to store your favorite snippets of code, it's very handy to quickly find and share code snippets that address common problems.

    • First enter GitHub to create a new personal API to access tokens;
    • Run Sublime, select menu Preferences –> Package Settings –> GitHub –> Settings-Default , copy the above generated token to the github_token field, save.

After that you can press the shortcut key Ctrl+Shift+P , select GitHub: Open Gist in Editor , and then choose your own Gist.

Installing and configuring Vim

With the Sublime Text, most of the cases do not need VI, but there are some times to make a small change or VI is the most convenient. Ubuntu default installation should already include VIM, if not, run the following command to install VIM.

1
sudo apt-get install vim

Then, refer to Amix ' s VIMRC to configure Vim.

At this point, all the basic environment has been equipped to complete, I hope these configuration can be helpful to everyone, the following is a well-configured interface screenshot.

Excerpted from http://blog.csdn.net/kingppy/article/details/13080919

Configure a comfortable Python development environment under Ubuntu

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.