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

时间:2023-01-25 09:14:53

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

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

7 个解决方案

#1


22  

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:

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

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

#2


29  

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.

别。 Apple提供各种依赖系统Python的系统实用程序(特别是Python“框架”构建);删除它会导致你的问题。

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

相反,修改〜/ .bash_profile中的PATH环境变量,首先放入/ opt / local / bin。

#3


20  

Use the python_select port to switch python interpreters.

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

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.

这将symlink / opt / local / bin / python添加到所选版本。然后如上所述导出PATH。

#4


17  

python_select is now deprecated, use this instead:

python_select现已弃用,请改用:

sudo port select python python26

#5


4  

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

而不是卸载内置的Python,安装MacPorts版本,然后修改$ PATH以获得MacPorts版本。

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

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

#6


3  

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.

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

Your .profile should have this line:

你的.profile应该有这一行:

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.

如果没有,添加它,现在你的shell将搜索macport的bin / first,并且应该在系统python之前找到macports python。

#7


3  

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

当前的Macports安装程序会自动执行.profile PATH修改。

#1


22  

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:

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

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

#2


29  

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.

别。 Apple提供各种依赖系统Python的系统实用程序(特别是Python“框架”构建);删除它会导致你的问题。

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

相反,修改〜/ .bash_profile中的PATH环境变量,首先放入/ opt / local / bin。

#3


20  

Use the python_select port to switch python interpreters.

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

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.

这将symlink / opt / local / bin / python添加到所选版本。然后如上所述导出PATH。

#4


17  

python_select is now deprecated, use this instead:

python_select现已弃用,请改用:

sudo port select python python26

#5


4  

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

而不是卸载内置的Python,安装MacPorts版本,然后修改$ PATH以获得MacPorts版本。

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

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

#6


3  

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.

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

Your .profile should have this line:

你的.profile应该有这一行:

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.

如果没有,添加它,现在你的shell将搜索macport的bin / first,并且应该在系统python之前找到macports python。

#7


3  

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

当前的Macports安装程序会自动执行.profile PATH修改。