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