1. Pip is used for package management
Document:
Https://pip.pypa.io/en/latest/installing.html
(sudo) pip install Django==1.6.8
(sudo) pip install bpython --upgrade
(sudo) pip install BeautifulSoup4 fabric virtualenv
(sudo) pip install –r requirements.txt
(sudo) pip uninstall xlrd
pip freeze > requirements.txt
2. Virtualenv independent Python environmental management
Document:
Http://virtualenvwrapper.readthedocs.org/en/latest/
Virtualenv is a package that creates a Python stand-alone environment, and virtualenvwrapper makes virtualenv more useful
(sudo) pip install virtualenv virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/workspace
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv
ENV: Create a running environment ENV
rmvirtualenv
ENV: Remove the operating environment ENV
mkproject
mic: Create a mic project and run environment mic
mktmpenv:
Create a temporary running environment
workon
bsp: Works in a bsp running environment
lsvirtualenv:
Lists the available operating environments
lssitepackages:
Lists the packages installed in the current environment
The environment you create is independent, non-disturbing, and you can use pip for package management without sudo permissions.
Here's a demo:
3. Fabric server management and app publishing
Website:
http://www.fabfile.org/
Document:
Http://docs.fabfile.org/
fabric: application deployment or systems administration tasks
from fabric.api import *
env.hosts = ['user@server1','user2@server2']
def ls_home():
with cd('/home/bae/'):
run('ls')
'''
常用命令
lcd(dir): 进入本机某目录
local(cmd): 本机上执行命令
cd(dir): 进入服务器某目录
run(cmd):服务器上执行命令
'''
Save the file above as
fabfile.py
enter the directory of the file on the terminal and execute
fab 函数名
比如:
fab ls_home
For more information, see the official documentation.