如何清理我的Python安装以重新开始 [英] How to clean up my Python Installation for a fresh start

查看:302
本文介绍了如何清理我的Python安装以重新开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Snow Leopard上进行开发,并通过各种操作方法"来安装并运行MySQLdb软件包(艰难的战斗).事情一团糟,我想通过全新的,干净的,接近工厂安装的Python 2.6恢复信心.

I'm developing on Snow Leopard and going through the various "how tos" to get the MySQLdb package installed and working (uphill battle). Things are a mess and I'd like to regain confidence with a fresh, clean, as close to factory install of Python 2.6.

我应该清除哪些文件夹?

What folders should I clean out?

我应该跑什么?

我应该销毁或创建哪些符号链接?

What symbolic links should I destroy or create?

推荐答案

您不应 要做的一件事是尝试删除或更改任何Apple提供的python文件或链接:它们位于/usr/bin/System/Library/Frameworks/Python.framework.这些是OS X的一部分,由Apple管理.清理为该Python安装的所有不必要的程序包都很好.它们在/Library/Python中.如果您安装了python.org Python并想将其删除,则大多数文件位于/Library/Frameworks/Python.framework中.有关如何删除它们的完整说明,请参见此处.而且,您安装到/usr/local中的任何东西都是公平的游戏.

One thing you should not do is try to remove or change any of the Apple-supplied python files or links: they are in /usr/bin and /System/Library/Frameworks/Python.framework. These are part of OS X and managed by Apple. It is fine to clean up any unnecessary packages you have installed for that Python. They are in /Library/Python. If you installed a python.org Python and want to remove it, most of the files are in /Library/Frameworks/Python.framework. See here for complete instructions on how to remove them. And anything you installed into /usr/local is fair game.

使用virtualenv是个不错的主意,但是在OS X上,它的重要性稍差一些,在OS X上,框架构建的概念使得支持多个Python版本比在其他某些平台上更容易.

Using virtualenvs is a fine idea but it's slightly less important on OS X where the concept of framework builds makes it easier to support multiple Python versions than on some other platforms.

更大的问题(尤其是尝试将MySQL与Python结合使用)是正确安装和构建所有必需的非Python库,考虑到OS X可用的各种选项,这是不平凡的. Python实例以及运行在哪个OS X级别上,您可能需要32位或64位,或者可能需要两个版本的东西,例如MySQL客户端库和MySQLdb适配器.因此,我强烈建议使用 MacPorts 中的完整解决方案.这样一来,您就有很大的机会轻松兼容地构建所有合适的组件.

The bigger issue, especially trying to use MySQL with Python, is getting all of the necessary non-Python libraries installed and built properly which is non-trivial given the variety of options available on OS X. For instance, depending on which Python instance and which OS X level running, you may need 32-bit or 64-bit or, possibly, both versions of things like the MySQL client libraries and the MySQLdb adapter. For that reason, I highly recommend using a complete solution from MacPorts. That way you have a good chance of getting all the right components built compatibly - and easily.

如有必要,请按照MacPorts网站上的说明安装基本MacPorts,然后:

If necessary, install the base MacPorts as described on the MacPorts website then:

$ sudo port selfupdate
$ sudo port install py26-mysql 

,它将插入并构建您需要的所有内容,并使其在/opt/local/bin中可用.还有很多其他可用的端口,例如:

and that will pull in and build everything you need and make it available in /opt/local/bin. There are also plenty of other ports available, for instance:

$ sudo port install py26-virtualenv

这篇关于如何清理我的Python安装以重新开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆