2

I have been enjoying learning the basics of python, but before I started reading things I tried to install various python versions and modules clumsily. Now that I have some ideas of what I want to do and how to do it I'm finding that various aspects are broken. For instance, 2.6 IDLE won't launch, and when I try to import modules they usually don't work.

My question is, how would you recommend I clean this up and start fresh? I have read information about modifying the 2.6 install, but I still can't get it to work.

IDLE 2.4 works, and when I launch python from the terminal I am running python 2.4.4.

4

3 回答 3

4

I had this problem so much when I first got my Mac. The best solution I found was to delete everything I'd installed and just go with the pythonmac.org version of Python (2.6). I then installed setuptools from the same site, and then used easy_install to install every other package.

Oh, and I got the GNU C Compiler from the Xcode developer tools CD (which you can download from Apple's website), so that I can compile C extensions.

于 2008-10-28T03:28:57.907 回答
1

Macports 应该很容易摆脱;只需删除 /opt/local/。我认为芬克做了类似的事情。

您可以which python查看默认的python是什么。系统python应该在/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python

您可能已经下载的 MacPython 位于 /Library/Frameworks/Python.framework 中。您也可以删除它。

此外,MacPython 和 MacPorts 都会编辑您的 ~/.profile 并更改 PYTHONPATH,确保对其进行编辑并删除那里的额外路径。

于 2008-10-30T00:08:53.457 回答
1

重新开始使用 Mac Ports 或 Fink 的最简单方法是简单地删除文件夹/sw/(对于 fink)或/opt/对于 MacPorts。

要完全删除它们,您必须删除~/.profile文件中的一行:

对于芬克:

test -r /sw/bin/init.sh && . /sw/bin/init.sh

..对于 MacPorts,我目前没有安装它,但会有一些类似的东西:

export PATH=$PATH:/opt/local/bin
export PATH=$PATH:/opt/local/sbin

至于安装 Python,目前最干净的方法是从源代码构建它。

我在这里写了我是如何在 Leopard 上安装 Python 2.6 的。它是针对 2.6 beta 版本之一的,所以将curl -O行更改为最新版本!

简而言之,下载并解压缩最新的python 2.6 源代码 tarball,然后(在终端中)cd到您解压缩 tarball 的位置,并运行以下命令。

./configure --prefix=/usr/local/python2.6
make
sudo make install

这会将python2.6安装到/usr/local/python2.6/(最后一行需要sudo,所以会询问你的密码)

最后添加/usr/local/python2.6到 $PATH,通过在文件中添加以下行~/.profile

export PATH=$PATH:/usr/local/python2.6

然后,您将能够运行该python2.6命令。

理想情况下,您只需安装MacPython,但它似乎还没有像样的 Python 2.6 安装程序。

于 2008-11-13T06:24:42.223 回答