2010年10月22日 星期五 17:02
Working with easy_install
使用easy_install
Now that your Python environment is set up we can turn our attention to easy_install which is a Python program which automatically fetches packages from PyPI as well as any dependencies they have. It then installs them to the same Python environment where the easy_install program itself is installed.
现在,你的Python环境已建立,我们可以把注意力转向easy_install,这是一个Python程序,可以从PyPI自动获取软件包及其任何依赖。然后,将它们安装在与easy_install安装所在的Python环境下。
The easy_install program is actually part of a module called setuptools and is installed automatically by the virtualenv.py script you have just run above.
easy_install程序实际上是setuptools模块的一部分,已通过你刚才运行的virtualenv.py脚本自动安装了。
Full documentation for EasyInstall can be found at
http://peak.telecommunity.co
m/DevCenter/EasyInstall and although it is a powerful tool with many options for advanced users, its basic use is very straightforward. To give you a flavour of the common ways to use it we will run through some examples.
EasyInstall的全部文档在
http://peak.telecommunity.com/DevCenter/EasyInst
all,它是一个功能强大的工具,有许多参数供高级用户选择使用,但其基本的使用确非常简单。为了让你体验一下一般用法,我们将通过一些例子展示。
To install the latest version of the PasteDeploy package used by Pylons and its dependencies you would simply run this command:
要安装最新版本的PasteDeploy软件包用于Pylons,及其依赖关系,你只要简单地执行这个命令:
$ easy_install PasteDeploy
When you run this command EasyInstall will visit the Python Package Index and the Pylons download page to find the most appropriate version of each of the required packages and install them each in turn. The PasteDeploy package doesn't have any dependencies, but if it did, EasyInstall would search the Python Package Index for the most appropriate versions of the dependent packages and automatically download them too.
当您执行此命令,EasyInstall将访问PyPI和Pylons网站下载页面寻找每一个需要的软件包最适当的版本,并按顺序安装它们。PasteDeploy包没有任何依赖关系,但如果有,EasyInstall将在PyPI搜索依赖软件包最合适的版本,自动下载它们。
If you are using a virtual Python environment you have to add the path to the virtual environment's bin directory before the easy_install command. If you installed your virtual Python environment to the env directory as described above the command would be:
如果您使用的是一个虚拟的Python环境,在运行easy_install命令之前,你必须将虚拟环境中的bin目录添加到环境变量path中。如果你已按照上文所述安装虚拟的Python环境到env目录,那么命令将是:
$ env/bin/easy_install PasteDeploy
On Windows, commands such as easy_install are often real Windows applications so you can add the .exe extension to them if you prefer. A virtual Python environment on Windows installs programs to the Scripts directory rather than to the bin directory so on Windows the command would be:
在Windows环境下,命令如easy_install往往是真正的Windows应用软件,你可以将.exe扩展添加给它们,如果你喜欢。在Windows环境下,虚拟的Python环境将程序安装到Scripts目录,而不是bin目录,因此,在Windows中的命令将是:
$ env/Scripts/easy_install.exe PasteDeploy
Caution!
The rest of the chapters in the book assume that you will always add the correct path to your virtual Python environment scripts and the .exe extension if it is necessary on your platform.
注意!
在书中的其余章节假设你将一直添加正确的路径到虚拟的Python环境中的脚本和.exe扩展,如果在你的平台有必要的话。
Virtually all packages on the Python Package Index can be installed in the same way as we installed the PasteDeploy package above, simply by specifying their package name as the argument to the easy_install command.
几乎所有在PyPI的软件包都可以用相同的方式安装,如上述我们安装PasteDeploy软件包那样,只要通过指定软件包的名字作为easy_install命令的参数。
Installing Pylons
安装Pylons
Now that you have a virtual Python environment and know how to use easy_install on your platform it is time to install Pylons itself.
现在,你有一个虚拟的Python环境,并知道如何在你的平台使用easy_install,现在是时候安装Pylons。
Pylons is made up from lots of different packages which all need to be installed for Pylons to work. Pylons itself is distributed under the open source license listed in the Preface of the book. All its dependencies are also open source too but if you are concerned about the details of the licenses you should check each package.
Pylons是由许多不同的软件包组成,要使Pylons工作,所有这些软件包都需要安装。Pylons是按本书序中所列的开源许可证发布的。其所有的依赖软件包也是开放源码,如果您关心许可证的细节,你应该查看每个软件包。
Rather than leaving you to install each package separately, Pylons uses the EasyInstall system you've just learned about to download and install all of its dependencies automatically.
不是让你单独安装每个软件包,Pylons可以使用你刚刚了解到的EasyInstall,自动下载并安装其所有依赖关系软件包。
At a command prompt run this command to install the latest version of Pylons and its dependencies:
在命令提示符下运行此命令,以安装最新版本的Pylons及其依赖:
$ easy_install Pylons
At the end of the process you should have the latest version of Pylons and all its dependencies installed and ready to use.
在这一过程结束时,你应该安装好最新版本的Pylons及其所有依赖,可以使用了。
Tip
If you are a Windows user and are using Python 2.3 you will also need to install a package called subprocess which you can download from
http://www.pylonshq.co
m/download/subprocess-0.1-20041012.win32-py2.3.exe. Python 2.4 and users and above already have this package.
Incidentally, Pylons may not support Python 2.3 for very much longer because of its lack of decorator support so you would be wise to upgrade to a more recent version like Python 2.5.
提示
如果你是一个Windows用户,并使用Python 2.3,你还需要安装一个subprocess软件包,下载
http://www.pylonshq.com/download/subprocess-0.1-20041012.win
32-py2.3程序。Python 2.4以上的用户已经有这个软件包。
顺便说一句,Pylons可能不会支持Python 2.3很长时间,因为它缺乏修饰器(decorator)支持,你应明智地升级到最新版本如Python 2.5。
If you want to make sure you have the latest version of Pylons you can use this command:
如果您要确认您有最新版本的Pylons,你可以使用此命令:
$ easy_install -U Pylons
This will install the latest version if it is not already present or upgrade Pylons to the latest version if an old version has already been installed.
如果Pylons尚未安装,这将安装最新版本,如果旧版本已经安装,升级到最新版本。
If you are using a virtual Python environment you will see that the pylons module has been installed into the virtual environment:
如果你使用的是虚拟的Python环境,你会看到,Pylons的模块已安装到虚拟环境:
C:\>C:\env\Scripts\python.exe
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylons
>>>
BUT: If you try to do the same with the system Python executable you'll get an error because the virtual Python installation has isolated the packages from the main system Python as we expected:
但是:如果你对系统的Python可执行程序尝试这样做,你会得到一个错误,因为虚拟的Python安装将软件包从系统的Python孤立出来了,因此我们可以预期:
C:\>C:\Python25\python.exe
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pylons
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pylons
>>>
Now that you have successfully installed Pylons and all its dependencies you are able to move on to Chapter 3 Getting Started but if you really want a thorough understanding, read on!
现在您已经成功安装Pylons及所有依赖,,如果你真的想深入了解,你可以进入第3章入门,继续阅读!
原文: http://hi.baidu.com/zhuifengdenanhai/blog/item/7fd19c588fb7a9d99d820400.html
Zeuux © 2024
京ICP备05028076号