Pylons  - 讨论区

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

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

Virtualenv Options
Virtualenv选项

The virtualenv.py script has two interesting command-line options which you can use when creating your virtual Python environment:

virtualenv.py脚本有两个有趣的命令行选项,当你建立虚拟的Python环境时,你可以使用它们:

--no-site-packages 
don't make the global site-packages directory accessible in the virtual environment
在虚拟环境中不能访问全局的site-packages目录, 
--clear 
delete any previous install of this virtualenv and start from scratch 
删除任何以前安装的virtualenv,从新开始

In the instructions above we've used the --no-site-packages option but you can leave this option out if you would prefer your virtual Python environment to also have access to all the packages already installed into the system Python environment.

在上述指示我们已经使用了--no-site-packages选项,当然你也可以不用这个选项,如果你希望你的虚拟的Python环境,也可以访问已经安装到系统中的Python环境的所有的软件包。

Choosing Package Versions with EasyInstall
EasyInstall与选择软件包的版本

EasyInstall allows you to be very specific about the version of a particular piece of software you want to install. Let's use the PasteDeploy package again as an example.

EasyInstall可以让你非常具体的选择要安装的软件的版本。让我们再次使用PasteDeploy包作为一个例子。

To install the latest version of the PasteDeploy package used by Pylons and its dependencies you would simply run this command as we've already seen:

要安装最新版本的Pylons所使用的PasteDeploy包及其依赖包,你只需执行这个命令,正如我们已经看到的:

$ easy_install PasteDeploy

To install PasteDeploy version 1.7 you would use:
要安装PasteDeploy 1.7版本,你可以使用下面这个命令:

$ easy_install "PasteDeploy==1.7"

You can also have more complicated version requirements. For example to install a version of PasteDeploy between 1.5 and 1.7 inclusive you could do this:

您也可以使用更复杂的版本要求。例如,安装了介于1.5和1.7之间的某个版本的PasteDeploy,你可以这样做:

$ easy_install "PasteDeploy>=1.5,<=1.7"

EasyInstall can also be used to upgrade packages. You use the easy_install command in a similar way but specify the -U flag to tell EasyInstall to upgrade the package. Notice how you can still specify version requirements even when upgrading:

EasyInstall也可以被用来升级软件包。你可以以同样的方式使用easy_install命令,只是要指定-U选项告诉EasyInstall升级软件包。请注意,即使升级,你仍然可以指定所需的版本:

$ easy_install -U "PasteDeploy>=1.5,<=1.7"

Of course, you can also use EasyInstall to directly install eggs that exist on your local system. For example, to install the Python 2.4 egg for PasteDeploy you could issue this command:

当然,你也可以使用EasyInstall直接安装在你的本地系统上的eggs。例如,安装Python 2.4版egg格式的PasteDeploy,你可以使用此命令:
$ easy_install PasteDeploy-1.7-py2.4.egg

Finally, EasyInstall can also be used to install source distributions which were created with the old distutils module which forms part of the Python distribution and which EasyInstall is designed to replace:

最后, EasyInstall还可以用来安装使用旧的distutils模块建立的源码发布,distutils模块是Python发行版的组成部分,将被EasyInstall取代:

$ easy_install  http://pypi.python.org/packages/source/P/PasteDeploy/PasteDeploy-1.5.tar.gz

In this case EasyInstall first creates a .egg file from the source distribution and then installs it. Notice that EasyInstall is equally happy taking local files or URLs as arguments.

在这种情况下,EasyInstall首先从源码分布创建一个.egg文件,然后安装它。请注意,EasyInstall同样可以使用本地的文件或URLs作为参数。


Tip

EasyInstall itself works by maintaining a file in your Python installation's lib/site-packages directory called easy_install.pth. Python looks in .pth files when it is starting up and adds any module zip files or paths specified to its internal sys.path. EasyInstall simply maintains the easy_install.pth file so that the packages it installs can be found by Python.

If you ever want to remove a package the easiest way is to remove its entry from the easy_install.pth file. You shouldn't ever need to remove a pacakge though because EasyInstall will always use the last one you installed by default.

提示

EasyInstall是维护在你的Python安装目录下lib/site-packages目录中的easy_install.pth来保持工作的。Python启动时,总是查看 .pth文件,然后将其中指定的所有模块档案文件和路径加入Python解释器内部的sys.path。 EasyInstall只是维护easy_install.pth文件,这样它所安装的软件包,都能很容易被Python找到。 
如果你要删除一个软件包,最简单的方法是删除easy_install.pth文件中的条目(路径)。你不需要删除包,因为EasyInstall将永远默认使用最后一个你安装的。


Installing with a Proxy Server
安装一个代理服务器

XXX JG: This section has not been tested yet.
XXX JG:本节尚未测试。

If you try to install Pylons using easy_install and get a message such as error: Download error: (10060, 'Operation timed out') it might be because your computer is behind an HTTP proxy and so easy_install cannot download the files it needs.

如果你尝试使用easy_install安装Pylons,获得了错误提示信息,如:下载错误:(10060,'操作超时'),这可能是因为你的电脑网络直接连接,需要HTTP代理,因此easy_install无法下载需要的文件。

For easy_install to be able to download the files you need to tell it where the proxy is. You can do this by setting the HTTP_PROXY environment variable. On Linux you would type:

为了使easy_install能够下载文件,你还需要告诉它代理。为此,你可以通过设置环境变量http_proxy。在Linux上,你可以输入:

export HTTP_PROXY=" http://yourproxy.com:port "

or if you need proxy authentication:
或者,如果你需要代理认证:

export HTTP_PROXY=" http://user:password@yourproxy.com:port "

On Windows you would set:
在Windows上,你可以输入:

set HTTP_PROXY=http://your.proxy.com:yourPort

You should then be able to run easy_install Pylons again and this time the program will be able to find the files. See the next section for installing Pylons offline if you still have difficulties.

然后,你可以再次运行easy_install安装Pylons,这一次,程序将能够找到文件。如果你仍然有困难,请参阅下一节,离线安装Pylons。

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

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

    你的回复:

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

    Zeuux © 2024

    京ICP备05028076号