Python Essential Artifact

Source: Internet
Author: User

1. PIP for package management

Document: Https://pip.pypa.io/en/latest/installing.html

# installation, can specify version number
(sudo) pip install django==1.6.8

# Upgrade
(sudo) pip install Bpython--upgrade

# install more than one at a time
(sudo) pip install BEAUTIFULSOUP4 fabric virtualenv

# Install from text, the text is a package name, one line, you can specify a version number
(sudo) pip Install–r requirements.txt

# Delete
(sudo) pip uninstall xlrd

# Export currently installed packages
Pip Freeze > Requirements.txt

2. virtualenv Independent Python Environment management

Document: http://virtualenvwrapper.readthedocs.org/en/latest/

Virtualenv is a package that creates a python-independent environment, Virtualenvwrapper makes virtualenv more usable

Installation
(sudo) pip install virtualenv Virtualenvwrapper

# Modify. Bash_profile or. ZSHRC (if you use zsh), add the following statement
Export Workon_home= $HOME/.virtualenvs
Export Project_home= $HOME/workspace
source/usr/local/bin/virtualenvwrapper.sh

Mkvirtualenv env: Creating a running environment env

Rmvirtualenv ENV: Remove the operating environment env

Mkproject Mic: Create MIC Project and run environment mic

Mktmpenv: Creating a temporary runtime environment

Workon BSP: Working in BSP operating environment

LSVIRTUALENV: List the available run environments

Lssitepackages: Lists the packages that are installed in the current environment

The created environment is independent, non-intrusive, and requires no sudo permission to manage the package using PIP.

Here's how to use the demo diagram:

3. Fabric Server Management and application publishing

Official website: http://www.fabfile.org/

Document: http://docs.fabfile.org/

Fabric:application deployment or systems administration tasks

#coding: Utf-8

From FABRIC.API Import *

# server List
env.hosts = [' [email protected] ', ' [email protected] '

Def ls_home ():
With CD ('/home/bae/'):
Run (' ls ')

‘‘‘
Common commands

LCD (dir): Enter the local directory
Local (CMD): Execute commands on this machine
CD (dir): Enter a server directory
Run (CMD): Execute command on server
‘‘‘

Save the above file as a fabfile.py on the terminal to enter the file directory, execute

Fab function name
Like what:
Fab ls_home

See the official documentation for more information on how to use.

Python Essential Artifact

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.