想要在我的 Mac 上安装可靠的 Python 程序吗?
我有安装了 Xcode 的 Mac OSX 10.5.8。我想避免 MacPorts,只想获得一个坚实的 Python 安装基础,这样我就可以继续处理 Django 和其他东西。我想在我的 Python 应用程序中使用 Buildout。
我已经从官方网站安装了二进制 Python 2.6.4 并安装了它。按照其他建议,我已将其放入我的 ~/.bash_profile
文件中:
export PATH=/usr/local/bin:$PATH
因此,当我执行 which python
时,它会显示 /usr/local/bin/python
。而且,当我执行 python -V
时,它显示 Python 2.6.4
- 这一切看起来都很棒。
我查看了 /usr/local/bin/
文件夹,除其他外,我似乎有指向 Python 2.6 的正确内容:
python -> ../../../Library/Frameworks/Python.framework/Versions/2.6/bin/python
但是,当我执行 easy_install< virtualenv 的 /code> (我想与 Buildout 一起使用)似乎将其安装在
/Library/Python/2.5/site-packages/virtualenv-1.4.3-py2.5.egg
中
。 ..Python 2.5 是什么?另外,当我使用 virtualenv 设置 Buildout 文件夹时,其中的 .Python 符号链接将是:
.Python -> /System/Library/Frameworks/Python.framework/Versions/2.5/Python
这是为什么?我不明白这一点。我怎样才能让它全部指向正确的Python 2.6?
非常感谢您的回答,这让我很恼火。干杯。
I have Mac OSX 10.5.8 with Xcode installed. I want to avoid MacPorts and want to just get a solid Python install foundation so I can then move on to mess with Django and other things. I want to use Buildout with my Python applications.
I have installed binary Python 2.6.4 from the official site and installed this. Following other advice I have put this in my ~/.bash_profile
file:
export PATH=/usr/local/bin:$PATH
So, when I do a which python
it shows /usr/local/bin/python
. And, when I do a python -V
it shows Python 2.6.4
- this all seems great.
I've looked inside the /usr/local/bin/
folder and, among other things, I seem to have the correct stuff pointing to Python 2.6:
python -> ../../../Library/Frameworks/Python.framework/Versions/2.6/bin/python
BUT, when I do an easy_install
of virtualenv (that I want to use with Buildout) it seems to install it in /Library/Python/2.5/site-packages/virtualenv-1.4.3-py2.5.egg
...which is Python 2.5? Also, when I setup my Buildout folder using virtualenv, in there the .Python
symlink is going to:
.Python -> /System/Library/Frameworks/Python.framework/Versions/2.5/Python
Why is this? I don't understand this. How can I get it all pointing to the correct Python 2.6?
Thank you so much for any answers, it's annoying the hell out of me. Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
首先,绝对不需要安装新版本的 Python 来在 Leopard 中运行 Django。现有的 Python 2.5 工作得非常好,Django 与该版本 100% 兼容。
其次,如果您确实想将 virtualenv 与系统默认版本之外的其他 Python 版本一起使用,则只需在创建 virtualenv 时告诉它:
Firstly, there's absolutely no need to install a new version of Python to work on Django in Leopard. The stock Python 2.5 works absolutely fine, and Django is 100% compatible with that version.
Secondly, if you do want to use virtualenv with a different version of Python other than the system default, you simply need to tell it when you create the virtualenv:
当您安装新的 Python 实例时,您还需要为其安装新的
easy_install
副本。请按照经典 setuptools 版本或较新的 分发。无论哪种情况,对于 OS X 上的 python.org 2.6.4,easy_install
脚本都将安装在/Library/Frameworks/Python.framework/Versions/2.6/bin
中它应该位于 shell$PATH
上的/usr/bin
之前。When you install a new Python instance, you also need to install a new copy of
easy_install
for it. Follow the instructions for either the classic setuptools version or the newer Distribute. In either case, for the python.org 2.6.4 on OS X theeasy_install
script will be installed in/Library/Frameworks/Python.framework/Versions/2.6/bin
which should come before/usr/bin
on your shell$PATH
.就我个人而言,我所做的就是让我的系统 python 保持原样。
我使用以下命令来安装 2.4、2.5 和 2.6 版本的 Python:
使用 plone 集体的构建来获取使用 easy_install 和 PIL 安装的 python2.{4,5,6}(包括 libjpeg 支持)
从克隆集体。我喜欢把它放在 /home/dev/python-buildout 的
src 目录中添加一个新的 local.cfg 文件。您可以在此处指定要构建的内容。在构建文件中使用以下内容:
使用系统 python 进行引导,然后运行构建。
编译完所有内容后,您应该在此处有一个新的 python 二进制文件:
要使用它们,请将 bin 目录添加到您的路径中,或者在 bin 目录中获取“activate”脚本,这会将其设置为您的活动中的 python当前 shell
对于我正在处理的每个项目,我倾向于使用 no-site-packages 和适当版本的 Python 创建一个新的虚拟环境。
Personally, what I do is leave my system python completely as is.
I use the following to install 2.4, 2.5 and 2.6 versions of Python:
Use a buildout from the plone collective to get python2.{4,5,6} installed with easy_install and PIL (including libjpeg support)
Checkout the python buildout files from the plone collective. I like to put it in /home/dev/python-buildout
Add a new local.cfg file into the src directory. This is where you specify what you want to build. Use the following in your buildout file:
Bootstrap with your system python and then run the buildout.
When everything has been compiled, you should have a new python binaries here:
To use them, either add the bin directory to your path, or source the 'activate' script in the bin directory, which will set it as the active python in your current shell
For each project I'm working on, I tend to create a new virtual environment, using no-site-packages and the appropriate version of Python.
PirosBOX:~ piros$ python -V
Python 2.5.1
有 OSX 10.5.8 并且我可以很好地编写 django 应用程序:D
重要的是获得 Django 的 SVN 版本,更好!
PirosBOX:~ piros$ python -V
Python 2.5.1
Have OSX 10.5.8 and i write django apps fine :D
The important thing is to get the SVN release of Django, better!
当我必须这样做时,我发现以下两个链接特别有用:
http://jessenoller.com/2009/03/16/so-you-want-to-use-python-on-the-mac/
http://blog.captnswing.net/2009 /04/19/python-mod_wsgi-64bit-mac-os-x-105/
I found the following two links particularly useful when I had to do it:
http://jessenoller.com/2009/03/16/so-you-want-to-use-python-on-the-mac/
http://blog.captnswing.net/2009/04/19/python-mod_wsgi-64bit-mac-os-x-105/