简体   繁体   English

Python OS X 10.5开发环境

[英]Python OS X 10.5 development environment

I would like to try out the Google App Engine Python environment, which the docs say runs 2.5.2. 我想试试Google App Engine Python环境,文档说它运行2.5.2。 As I use OS X Leopard, I have Python 2.5.1 installed, but would like the latest 2.5.x version installed (not 2.6 or 3.0). 当我使用OS X Leopard时,我安装了Python 2.5.1,但是希望安装最新的2.5.x版本(不是2.6或3.0)。 It seems the latest version is 2.5.4 似乎最新版本是2.5.4

So, I went to here: 所以,我去了这里:

http://wiki.python.org/moin/MacPython/Leopard http://wiki.python.org/moin/MacPython/Leopard

and stopped because I am worried installing the latest version might mess with the standard install. 并且因为我担心安装最新版本可能会导致标准安装混乱而停止。 I really just want one version installed. 我真的只想安装一个版本。

So my questions are how do I safely install the latest 2.5.x? 所以我的问题是如何安全地安装最新的2.5.x? Is it possible to fully replace the built in version, and if so would that hurt any Mac tools? 是否可以完全替换内置版本,如果是这样会损害任何Mac工具?

Cheers, Shane 干杯,沙恩

You can install python on your Mac, and it won't mess with the default installation. 你可以在你的Mac上安装python,它不会搞乱默认安装。 However, I strongly recommend that you use MacPorts to install Python, since that will make it much easier for you to install Python libraries and packages further down the road. 但是,我强烈建议您使用MacPorts来安装Python,因为这将使您更容易安装Python库和软件包。 Additionally, if you try to install a program or library with MacPorts that depends on Python, MacPorts will download a copy of Python, even if you have MacPython installed, so you might end up with redundant copies of Python if you install MacPython but then choose to use MacPorts at a later date. 此外,如果您尝试使用依赖于Python的MacPorts安装程序或库,MacPorts将下载Python的副本,即使您安装了MacPython,因此如果您安装MacPython但最终可能会选择Python的冗余副本,以后使用MacPorts。 To install Python with MacPorts, download and install MacPorts, then type: 要使用MacPorts安装Python,请下载并安装MacPorts,然后键入:

sudo port install python25 python_select
sudo python_select python25

Run the following command to view all the MacPorts packages for Python: 运行以下命令以查看Python的所有MacPorts包:

port list | grep py25-

You can install any of the packages on the list by simply typing: 您只需键入以下内容即可在列表中安装任何软件包:

sudo port install packagename

In the above, replace packagename with the name of the package. 在上面,将packagename替换为包的名称。 On my first install I always run 在我第一次安装时,我总是跑

sudo port install py25-setuptools

[ NOTE: These commands need to be run from the Terminal -- Applications > Utilities > Terminal.app ] [注意:这些命令需要从终端 - 应用程序>实用程序> Terminal.app运行]

Your current python is in /System/Library/Frameworks/Python.framework/ . 您当前的python位于/System/Library/Frameworks/Python.framework/

If you install MacPython, it will go into /Library/Frameworks/Python.framework/ . 如果您安装MacPython,它将进入/Library/Frameworks/Python.framework/ The installer will modify your $PATH (environment variable) so that typing python at the command line will run the version it installs. 安装程序将修改$ PATH(环境变量),以便在命令行键入python将运行它安装的版本。

You can easily get back the old version by modifying the path again. 您可以通过再次修改路径轻松恢复旧版本。

You will have to reinstall any third-party modules you are using. 您必须重新安装正在使用的任何第三方模块。 This is because third-party modules go into Python.framework/Versions/Current/lib/python2.5/site-packages/ for the version you're running. 这是因为第三方模块进入Python.framework/Versions/Current/lib/python2.5/site-packages/用于您正在运行的版本。

Since you're not modifying the system version, you aren't in danger of affecting any Apple system tools that rely on it. 由于您没有修改系统版本,因此您不会有任何影响依赖它的Apple系统工具的危险。

(in fact, arguably it is safer to install MacPython from the start, and never touch the Apple-supplied version. See here for a similar situation involving Perl, where Apple updated the version of Perl in /System and broke a lot of people's setups) (事实上​​,可以说从一开始就安装MacPython更安全,而且从不接触Apple提供的版本。请参阅此处了解涉及Perl的类似情况,其中Apple在/System更新了Perl版本并打破了很多人的设置)

You may also be interested in virtualenv . 您可能也对virtualenv感兴趣。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM