蟒蛇 + 豹+ 芬克+ Mac 端口 + Python.org + 白痴=破烂的Python - 新的开始?

发布于 2024-07-08 04:01:05 字数 268 浏览 10 评论 0原文

我一直很喜欢学习 python 的基础知识,但在开始阅读之前,我尝试笨拙地安装各种 python 版本和模块。 现在我对自己想要做什么以及如何做有了一些想法,但我发现各个方面都被打破了。 例如,2.6 IDLE 不会启动,当我尝试导入模块时,它们通常不起作用。

我的问题是,你会如何建议我清理这个并重新开始? 我已阅读有关修改 2.6 安装的信息,但仍然无法使其工作。

IDLE 2.4 可以工作,当我从终端启动 python 时,我正在运行 python 2.4.4。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

风透绣罗衣 2024-07-15 04:01:06

当我第一次拿到 Mac 时,我就经常遇到这个问题。 我发现的最好的解决方案是删除我安装的所有内容,然后使用 pythonmac.org 版本的 Python (2.6 )。 然后我从同一站点安装了 setuptools,然后使用 easy_install 安装所有其他软件包。

哦,我从 Xcode 开发工具 CD(可以从 Apple 网站下载)中获得了 GNU C 编译器,这样我就可以编译 C 扩展。

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.

野却迷人 2024-07-15 04:01:06

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,请确保对其进行编辑并删除其中的额外路径。

Macports should be easy to get rid of; just delete /opt/local/. I think that Fink does something similar.

You can do which python to see what python is the default one. The system python should be in /System/Library/Frameworks/Python.framework/Versions/2.5/bin/python

The MacPython you may have downloaded would either be in /Library/Frameworks/Python.framework. You can delete this as well.

Also, both MacPython and MacPorts edit your ~/.profile and change the PYTHONPATH, make sure to edit it and remove the extra paths there.

久而酒知 2024-07-15 04:01:06

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

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

对于 fink:

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安装程序还没有。

The easiest way to start afresh with Mac Ports or Fink is to simply remove the folder /sw/ (for fink) or /opt/ for MacPorts.

To completely remove them, you will have to remove a line in your ~/.profile file:

For fink:

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

..and for MacPorts, I don't have it installed currently, but there will be something along the lines of:

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

As for installing Python, currently the cleanest way is to build it from source..

I wrote up how I installed Python 2.6 on Leopard here. It was for one of the 2.6 beta releases, so change the curl -O line to the newest release!

In short, download and extract the latest python 2.6 source tarball, then (in a terminal) cd to where you extracted the tarball, and run the following commands..

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

That will install python2.6 into /usr/local/python2.6/ (the last line requires sudo, so will ask you for your password)

Finally add /usr/local/python2.6 to $PATH, by adding the following line you the file ~/.profile

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

Then you will be able to run the python2.6 command.

Ideally you would just install MacPython, but it doesn't seem to have a decent Python 2.6 installer yet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文