您的位置:首页 > 编程语言 > Python开发

Python项目部署的三大神器

2017-04-14 22:37 483 查看
对于Python这种自带电池的语言来说,避免项目开发、部署的导致的系统混乱,为每个项目定制一个自己的环境十分重要。这三个工具都有详细的文档,建议大家有时间就阅读文档学习吧。本文只是根据自己的使用对其中常用的做简要说明。

如果你已经阅读了官方文档,我认为你大可不必浪费时间再看这篇文字了。

目录

一 pip
pip中英文官方文档

pip简介

pip安装

pip使用

二 virtualenv
virtualenv中英文官方文档

virtualenv简介

利用virtualenv 创建虚拟python环境

virtualenv使用

三 fabric
fabric中英文官方文档

fabric简介

fabric安装

fabric使用

一 pip

pip中英文官方文档

pip.pypa.io

pip-chinese-docs

pip简介

pip 用来解决项目依赖问题。将项目所有依赖的第三方库写在一个requirements.txt 中用pip批量安装。一般和virtualenv 配合使用,将所有包安装在virtualenv 的环境中。这样既可以让我们的系统保持高度的纯净。

pip安装

Python 3.5
之后会在安装时勾选同时安装
pip
省去很多麻烦。

如果在Windows/Linux系统中安装,传送门.

pip使用

pip install [options] <requirement specifier> ...
pip install [options] -r <requirements file> ...
pip install [options] [-e] <vcs project url> ...
pip install [options] [-e] <local project path> ...
pip install [options] <archive url/path> ...


如安装
virtualenv


pip install virtualenv


二 virtualenv

virtualenv中英文官方文档

virtualenv.pypa.io

virtualenv-chinese-docs

virtualenv简介

virtualenv 用来建立一个虚拟的python环境,一个专属于项目的python环境。用virtualenv 来保持一个干净的环境非常有用。virtualenv自己的介绍

virtualenv
is a tool to create isolated Python environments.

The basic problem being addressed is one of dependencies and versions, and indirectly permissions. Imagine you have an application that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications If you install everything into
usrlibpython2.7site-packages
(or whatever your platform’s standard location is), it’s easy to end up in a situation where you unintentionally upgrade an application that shouldn’t be upgraded.

Or more generally, what if you want to install an application and leave it be If an application works, any change in its libraries or the versions of those libraries can break the application.

Also, what if you can’t install packages into the
global site-packages
directory For instance, on a shared host.

In all these cases,
virtualenv
can help you. It creates an environment that has its own installation directories, that doesn’t share libraries with other virtualenv environments (and optionally doesn’t access the globally installed libraries either). —— [ virtualenv-introduction ]

利用virtualenv 创建虚拟python环境

使用virtualenv来创建虚拟python环境。virtualenv本是一个独立的工具,官网在这里:https://pypi.python.org/pypi/virtualenv

virtualenv使用

另一篇文章

1.Django开发环境搭建

三 fabric

fabric中英文官方文档

fabfile.org

fabric-chinese-docs

fabric简介

fabric安装

fabric使用

end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python virtualenv pip fabric