Python Development Environment Configuration

Source: Internet
Author: User

Based on Linux/mac OS X. Perhaps a lot of friends and I want to, but also afraid of their own forgotten.

First, version of the Platform 1, system platformThe configuration of this development environment is based on Linux or Mac OS X, which has not been tested for windows, so it is not good to say that it should be the same. However, personal advice, Python development or on Linux or OS X platform, these two systems for Python provides native support. At least the system comes with it.Python for Ubuntu 12.04: Version 2.7.3(not to say otherwise, but other versions have not been tested) of course, the system version is more than 12.04 is also possibleOS X 10.9 comes with Python: version Yes 2.7.5Ii. configuration of the virtual Environment 1, description of the virtual environmentPython has a lot of versions, from 2.5 to 3.x, and the compatibility between versions and third-party packages is not very good, and in order for each of them to have an isolated environment that does not affect each other, a virtual environment is necessary to isolate each version. I have a deep understanding, because the compatibility problem is a mistake, but the more deadly is still do not know how to modify, often changed this one has errors, so the virtual environment is necessary.then install the required packages in each environment (with pipuse), this series of environments are isolated from each other. 2, install the configuration Linux (here specifically Ubuntu) on the installation please first ensure that the following two steps:
sudo apt-get install build-essentialsudo aptitude Install Python-dev


Linux installation Pip
sudo apt-get install Python-pip
OS x also installs Pip first
sudo easy_install pip

And then the way to install Virtualenv,linux and OS X is the same with PIP.


3, convenient use of virtual environment: Virtualenvwrapper

Installation:

sudo pip install Virtualenvwrapper

Configure Virtualenvwrapper

Modify

sudo vim  /usr/local/bin/virtualenvwrapper.sh
Modify the directory where you want the virtual environment to be, and its default path is $home/.virtualenvs

I changed it to $home/virtualenvs.

Perform:

source/usr/local/bin/virtualenvwrapper.sh
So the management tools are doing well

Third, how to useThanks to the virtualenvwrapper installed in the previous step, we can easily use and manage the virtual Environment 3.1 create a virtual environment the next operation is to create a virtual environment (that is, a directory), the path created by this virtual environment is $home/virtualenvs, In the Virtualenvs of your home directory.
Mkvirtualenv test2-pyenv
Check ~/virtualenvs again and find out more test2-pyenv
Once created, the virtual environment is automatically activated and the command prompt changes to this:
(test2-env) Terminal_user> test2-env$

3.2 List all Virtual environments
$ lsvirtualenv



3.3 List all Virtual environments
$ lsvirtualenv


3.4 Activating a virtual environment
$ Workon test2-env


3.5 Entering the Virtual environment directory
$ cdvirtualenv


3.6 Enter the Site-packages directory of the virtual environment
$ cdsitepackages



3.7 Listing all packages for the Site-packages directory
$ lssitepackages



3.8 Stopping a virtual environment
$ deactivate



3.9 Deleting a virtual environment
$ rmvirtualenv test2-env


In addition: when we migrate the environment and rebuild it is also very convenient 4, rebuild the Python environment

4.1 Placing the package configuration in a file$ pip freeze > Requirements.txt4.2 Rebuilding and rebuilding (rebuild) environment is when deploying, install the corresponding version of the package in the production environment, do not appear version compatibility and other issues:


$ pip install-r requirements.txt


Reference: Click to open link
Click to open link



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Python Development Environment Configuration

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.