Pylons  - 讨论区

标题:转:【翻译】The Definitive Guide to Pylons(五)

2010年10月22日 星期五 17:00

2. Installation
2.安装
Pylons is written in the Python language and is designed to run on any platform which supports a modern version of Python. It can therefore be used on Windows, Mac OS X, Linux, BSD and many other platforms. Because Python is an interpreted language, Pylons applications you write for one platform will be able to run on other platforms without any modification.

Pylons是Python语言编写的,目的是运行在任何平台上,这个特性是由Python支持。因此Pylons可以在Windows,Mac OS X,Linux,BSD和许多其他平台使用。由于Python是一种解释型语言,你在一个平台编写的Pylons应用将能够运行其他平台上,不需要任何改动。

There are actually quite a few different ways to install Pylons depending on your needs but the three main tools most Pylons developers use are:

其实有不少不同的方式选择来按照您的需要安装Pylons,而且三个主要工具,大部分Pylons开发者都会用到:

 • A virtual Python Environment 
 • The easy_install program 
 • The Python Package Index

 • 一个Python虚拟环境 
 • easy_install程序 
 • Python软件包索引

In this chapter we'll look at what a virtual Python environment is before turning our attention to the Python Package Index and the easy_install program. Once we have a Pylons installation up and running we'll look at how to install packages with C or C++ extensions such as the database drivers for MySQL, PostgreSQL and SQLite. Once you have a thorough understanding of the install processes used by Pylons we'll turn our attention to Python itself and look at any subtleties you need to be aware of on your particular platform.

在这一章中我们将了解何为Python虚拟环境,然后把注意力转向the Python Package Index和easy_install程序。一旦我们安装和运行Pylons,我们将看看如何安装C或C + +的扩展包,如数据库的驱动程序MySQL和PostgreSQL和SQLite。一旦你对Pylons的安装过程有一个透彻的了解,我们将我们的注意力转向Python并看看你需要了解的关于你的特定平台的任何细微处。

Note

If you haven't got a copy of Python installed yet you might want to jump ahead to the platform-specific notes later in this chapter to learn how to install a recent version of Python such as 2.5 or 2.6 on your platform but since almost all platforms apart from Windows already come with a recent version of Python most of you will be able to create a virtual Python environment straight away.

注意

如果您尚未安装Python,稍后您可能要跳到在这一章中关于特殊平台的具体说明部分,以了解如何在你的平台上安装最新版本的Python,如2.5或2.6,因为除了Windows平台几乎所有的平台都已经配备了最新版本的Python,大多数人将能够直接建立一个Python虚拟环境。


Quick Start
快速起步

Pylons is actually very easy to install. If you are not so interested in the details but just want to get up and running with a Pylons installation on Linux as quickly as possible the steps below show you how. Steps specific to Windows and Mac OS are explained in the following sections.

Pylons实际上是非常容易安装。如果您不是如此对细节感兴趣,而只是想尽快在Linux上开始安装Pylons,下面的步骤将告诉您如何做。对于Windows和Mac OS的具体步骤的解释在以下各节。

1. Download the virtualenv.py script from  http://pylonsbook.com/virtualenv.py  

下载virtualenv.py脚本: http://pylonsbook.com/virtualenv.py

(Debian, and other distributions have a python-virtualenv package that provides /usr/bin/virtualenv which you can use instead if that is easier for you.)

(替代的方案:Debian,以及其他发行版都有python-virtualenv包,它提供了/usr/bin/virtualenv, 你觉得更容易的话 ,可以直接使用它。)

2. Create a virtual Python environment in a directory called env so that packages you install for Pylons do not affect any other programs using Python on your system. CD to the location where you wish to place the env directory, copying the virtualenv.py script there. A good place might be your home directory:

在env目录中创建一个虚拟的Python环境,这样Pylons安装的包不影响系统中任何其他使用Python的程序。将env目录放置在你希望的位置,复制virtualenv.py脚本到目录下。一个很好的地方可能是你的主目录:
python virtualenv.py --no-site-packages /home/james/pylonsenv

3. Use the easy_install program (which was automatically installed into your virtual Python environment by the command above) to install Pylons:

使用easy_install程序(通过上面的命令行自动安装到你的虚拟Python环境的)安装Pylons:
cd /home/james
pylonsenv/bin/easy_install "Pylons==0.9.7"

Windows users would use Scripts instead of bin in the above command but full details are explained later in the Windows-specific instructions.

Windows用户将使用Scripts目录而不是上述命令中的bin目录,稍后将详细解释有关Windows的具体指示。

Once the installation has finished you should always use the programs in env/bin rather than the scripts in your system Python installation. For example, where examples in the book specify something like this:

一旦完成安装,你应该总是使用在env/bin中的程序,而不是系统中的Python安装路径的程序。举例来说,在书中的例子会使用这样的命令:
paster serve --reload development.ini

you would actually need to type the following to have the command run from your virtual Python environment:

实际你应该需要键入以下的内容让命令从你的虚拟Python环境运行:

env/bin/paster serve --reload development.ini

If you don't quite understand the implications of the setup described above, please read the rest of the chapter for the full details.

如果你不明白上文所述中安装的含义,请阅读本章节其他部分,获取全部细节。

原文: http://hi.baidu.com/zhuifengdenanhai/blog/item/ae0baac2eb05dd1c0ef477a5.html

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号