如何从 OSX Leopard 卸载 python 以便可以使用 MacPorts 版本?

发布于 2024-07-06 02:16:30 字数 50 浏览 7 评论 0原文

我想使用 macports 版本的 python,而不是 Leopard 自带的版本。

I want to use the macports version of python instead of the one that comes with Leopard.

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

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

发布评论

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

评论(7

睡美人的小仙女 2024-07-13 02:16:30

我已经安装了:

$ which python
/usr/bin/python
$ which python2.5
/opt/local/bin/python2.5

我还在我的 .profile 中添加了以下行:

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

I have both installed:

$ which python
/usr/bin/python
$ which python2.5
/opt/local/bin/python2.5

I also added the following line to my .profile:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH
美胚控场 2024-07-13 02:16:30

使用 python_select 端口切换 python 解释器。

sudo port install python25
sudo port install python_select
sudo python_select python25

这会将 /opt/local/bin/python 符号链接到所选版本。 然后按照上面的描述导出PATH

Use the python_select port to switch python interpreters.

sudo port install python25
sudo port install python_select
sudo python_select python25

This will symlink /opt/local/bin/python to the selected version. Then export PATH as described above.

不忘初心 2024-07-13 02:16:30

python_select 现已弃用,请改用:

sudo port select python python26

python_select is now deprecated, use this instead:

sudo port select python python26
心的位置 2024-07-13 02:16:30

不要卸载内置 Python,而是安装 MacPorts 版本,然后修改您的 $PATH 以首先安装 MacPorts 版本。

例如,如果 MacPorts 安装 /usr/local/bin/python,则修改 .bashrc 以包含 PATH=/usr/local/bin:$PATH 在最后。

Instead of uninstalling the built-in Python, install the MacPorts version and then modify your $PATH to have the MacPorts version first.

For example, if MacPorts installs /usr/local/bin/python, then modify your .bashrc to include PATH=/usr/local/bin:$PATH at the end.

风吹雪碎 2024-07-13 02:16:30

我不会卸载它,因为许多脚本在不遵循约定并使用 #!/usr/bin/env python 时会期望 python 出现在通常的位置。 您只需编辑 .profile.bash_profile,以便 macports 二进制文件位于路径中的第一个。

您的 .profile 应该包含以下行:

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

如果没有,请将其添加进去,现在您的 shell 将首先搜索 macport 的 bin/,并且应该在系统 python 之前找到 macports python。

I wouldn't uninstall it since many scripts will expect python to be in the usual places when they do not follow convention and use #!/usr/bin/env python. You should simply edit your .profile or .bash_profile so the macports binaries are the first in your path.

Your .profile should have this line:

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

If not, add it in, and now your shell will search macport's bin/ first, and should find macports python before system python.

装迷糊 2024-07-13 02:16:30

当前的 Macports 安装程序会自动进行 .profile 路径修改。

The current Macports installer does the .profile PATH modification automatically.

梦里梦着梦中梦 2024-07-13 02:16:30

不。 Apple 发布了各种依赖于 Python 系统(特别是 Python“框架”构建)的系统实用程序; 删除它会给你带来问题。

相反,修改 ~/.bash_profile 中的 PATH 环境变量,将 /opt/local/bin 放在第一位。

Don't. Apple ships various system utilities that rely on the system Python (and particularly the Python "framework" build); removing it will cause you problems.

Instead, modify your PATH environ variable in your ~/.bash_profile to put /opt/local/bin first.

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