标签归档:uninstall

如何从macOS完全卸载Anaconda

问题:如何从macOS完全卸载Anaconda

如何从MacOS Sierra完全卸载Anaconda并恢复为原始Python?我试过使用,conda-clean -yes但不起作用。我也删除了其中的内容,~/.bash_profile但是它仍然使用Anaconda python,并且我仍然可以运行conda命令。

How can I completely uninstall Anaconda from MacOS Sierra and revert back to the original Python? I have tried using conda-clean -yes but that doesn’t work. I also remove the stuff in ~/.bash_profile but it still uses the Anaconda python and I can still run the conda command.


回答 0

删除配置:

conda install anaconda-clean
anaconda-clean --yes

删除配置后,您可以删除anaconda安装文件夹,该文件夹通常位于主目录下:

rm -rf ~/anaconda3

另外,该anaconda-clean --yes命令还会在您的主目录中以格式创建备份~/.anaconda_backup/<timestamp>。确保也删除该一个。


编辑(v5.2.0):现在,如果您要清除所有内容,则还必须删除添加到的最后两行.bash_profile。他们看着像是:

# added by Anaconda3 5.2.0 installer
export PATH="/Users/ody/anaconda3/bin:$PATH"

To remove the configs:

conda install anaconda-clean
anaconda-clean --yes

Once the configs are removed you can delete the anaconda install folder, which is usually under your home dir:

rm -rf ~/anaconda3

Also, the anaconda-clean --yes command creates a backup in your home directory of the format ~/.anaconda_backup/<timestamp>. Make sure to delete that one also.


EDIT (v5.2.0): Now if you want to clean all, you will also have to delete the two last lines added to your .bash_profile. They look like:

# added by Anaconda3 5.2.0 installer
export PATH="/Users/ody/anaconda3/bin:$PATH"

回答 1

要卸载Anaconda,请打开终端窗口:

  1. 删除整个anaconda安装目录:
rm -rf ~/anaconda
  1. 编辑~/.bash_profile 并从您的PATH环境变量中删除anaconda目录。

注意:您可能需要编辑.bashrc和/或.profile文件而不是.bash_profile

  1. 删除以下隐藏的文件和目录,这些文件和目录可能是在主目录中创建的:

    • .condarc
    • .conda
    • .continuum

用:

rm -rf ~/.condarc ~/.conda ~/.continuum

To uninstall Anaconda open a terminal window:

  1. Remove the entire anaconda installation directory:
rm -rf ~/anaconda
  1. Edit ~/.bash_profile and remove the anaconda directory from your PATH environment variable.

Note: You may need to edit .bashrc and/or .profile files instead of .bash_profile

  1. Remove the following hidden files and directories, which may have been created in the home directory:

    • .condarc
    • .conda
    • .continuum

Use:

rm -rf ~/.condarc ~/.conda ~/.continuum

回答 2

就我而言(Mac High Sierra),它安装在〜/ opt / anaconda3上。

https://docs.anaconda.com/anaconda/install/uninstall/

In my case (Mac High Sierra) it was installed at ~/opt/anaconda3.

https://docs.anaconda.com/anaconda/install/uninstall/


回答 3

打开终端,并输入以下命令,删除整个Anaconda目录,该目录的名称将为“ anaconda2”或“ anaconda3”,例如:rm -rf〜/ anaconda3。然后使用命令“ conda uninstall” https://conda.io/docs/commands/conda-uninstall.html删除conda 。

Open the terminal and remove your entire Anaconda directory, which will have a name such as “anaconda2” or “anaconda3”, by entering the following command: rm -rf ~/anaconda3. Then remove conda with command “conda uninstall” https://conda.io/docs/commands/conda-uninstall.html.


回答 4

这是anaconda在删除Anaconda之后有一个条目破坏了我的python安装的地方。希望这对其他人有帮助。

如果您使用的是纱,我在〜/“用户名”的.yarn.rc文件中找到了此条目

python“ / Users / someone / anaconda3 / bin / python3”

删除此行固定了彻底删除所需的最后一个位置。我不确定如何添加该条目,但它有帮助

This is one more place that anaconda had an entry that was breaking my python install after removing Anaconda. Hoping this helps someone else.

If you are using yarn, I found this entry in my .yarn.rc file in ~/”username”

python “/Users/someone/anaconda3/bin/python3”

removing this line fixed one last place needed for complete removal. I am not sure how that entry was added but it helped


回答 5

在执行了辣木和jkysam的非常有用的建议而没有立即获得成功后,需要简单地重新启动Mac才能使系统识别出更改。希望这对某人有帮助!

After performing the very helpful suggestions from both spicyramen & jkysam without immediate success, a simple restart of my Mac was needed to make the system recognize the changes. Hope this helps someone!


回答 6

这对我有用:

conda remove --all --prefix /Users/username/anaconda/bin/python

然后从.bash_profile中的$ PATH中删除

This has worked for me:

conda remove --all --prefix /Users/username/anaconda/bin/python

then also remove from $PATH in .bash_profile


回答 7

在我的〜/ .bash_profile文件中添加export PATH="/Users/<username>/anaconda/bin:$PATH"(或export PATH="/Users/<username>/anaconda3/bin:$PATH"如果您有anaconda 3),可以为我解决此问题。

Adding export PATH="/Users/<username>/anaconda/bin:$PATH" (or export PATH="/Users/<username>/anaconda3/bin:$PATH" if you have anaconda 3) to my ~/.bash_profile file, fixed this issue for me.


回答 8

官方说明似乎在这里:https : //docs.anaconda.com/anaconda/install/uninstall/

但是,如果您喜欢我,由于某种原因而无法使用,并且由于某种原因您的conda却安装在其他地方,并告诉您这样做:

rm -rf ~/opt

我不知道为什么将它保存在那里,但这就是我的目的。


这对我修复conda安装很有用(如果这是您像我这样首先卸载它的原因):https : //stackoverflow.com/a/60902863/1601580最后为我修复了它。不知道为什么conda首先表现得很怪异,或者为什么错误地首先把东西安装了……

The official instructions seem to be here: https://docs.anaconda.com/anaconda/install/uninstall/

but if you like me that didn’t work for some reason and for some reason your conda was installed somewhere else with telling you do this:

rm -rf ~/opt

I have no idea why it was saved there but that’s what did it for me.


This was useful to me in fixing my conda installation (if that is the reason you are uninstalling it in the first place like me): https://stackoverflow.com/a/60902863/1601580 that ended up fixing it for me. Not sure why conda was acting weird in the first place or installing things wrongly in the first place though…


如何在Mac OS X 10.6.4上卸载Python 2.7?

问题:如何在Mac OS X 10.6.4上卸载Python 2.7?

我想从Mac OS X 10.6.4中完全删除Python 2.7。我设法PATH通过还原删除了变量中的条目.bash_profile。但我也想删除所有由python 2.7安装包安装的目录,文件,符号链接和条目。我从http://www.python.org/获得了安装包。我需要删除哪些目录/文件/配置文件条目?某处有清单吗?

I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the entry from the PATH variable by reverting my .bash_profile. But I also want to remove all directories, files, symlinks, and entries that got installed by the Python 2.7 install package. I’ve got the install package from http://www.python.org/. What directories/files/configuration file entries do I need to remove? Is there a list somewhere?


回答 0

不要试图删除任何苹果公司提供的系统的Python这是在/System/Library/usr/bin,因为这可能会破坏你的整个操作系统。


注意: 以下列出的步骤不会影响Apple提供的系统Python 2.7;请参阅附录A。他们只会删除第三方Python框架,例如python.org安装程序安装的框架。


完整列表在此处记录。基本上,您需要做的是:

  1. 删除第三方Python 2.7框架

    sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
  2. 删除Python 2.7应用程序目录

    sudo rm -rf "/Applications/Python 2.7"
  3. 在中删除/usr/local/bin指向此Python版本的符号链接。看到他们使用

    ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' 

    然后运行以下命令删除所有链接:

    cd /usr/local/bin/
    ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
  4. 如有必要,请编辑您的外壳配置文件,以删除添加/Library/Frameworks/Python.framework/Versions/2.7到您的PATH环境文件中的操作。根据您所使用的shell,任何下列文件可能已被修改: ~/.bash_login~/.bash_profile~/.cshrc~/.profile~/.tcshrc,和/或~/.zprofile

Do not attempt to remove any Apple-supplied system Python which are in /System/Library and /usr/bin, as this may break your whole operating system.


NOTE: The steps listed below do not affect the Apple-supplied system Python 2.7; they only remove a third-party Python framework, like those installed by python.org installers.


The complete list is documented here. Basically, all you need to do is the following:

  1. Remove the third-party Python 2.7 framework

    sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
    
  2. Remove the Python 2.7 applications directory

    sudo rm -rf "/Applications/Python 2.7"
    
  3. Remove the symbolic links, in /usr/local/bin, that point to this Python version. See them using

    ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' 
    

    and then run the following command to remove all the links:

    cd /usr/local/bin/
    ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
    
  4. If necessary, edit your shell profile file(s) to remove adding /Library/Frameworks/Python.framework/Versions/2.7 to your PATH environment file. Depending on which shell you use, any of the following files may have been modified: ~/.bash_login, ~/.bash_profile, ~/.cshrc, ~/.profile, ~/.tcshrc, and/or ~/.zprofile.


回答 1

这个作品:

cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm

描述:列出所有链接,删除@字符,然后删除它们。

This one works:

cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm

Description: It list all the links, removes @ character and then removes them.


回答 2

如果使用PKG安装程序安装了它,则可以执行以下操作:

pkgutil --pkgs

或更好:

pkgutil --pkgs | grep org.python.Python

这将输出类似:

org.python.Python.PythonApplications-2.7
org.python.Python.PythonDocumentation-2.7
org.python.Python.PythonFramework-2.7
org.python.Python.PythonProfileChanges-2.7
org.python.Python.PythonUnixTools-2.7

您现在可以选择要取消链接(删除)的软件包。

这是取消链接文档:

 --unlink package-id
             Unlinks (removes) each file referenced by package-id. WARNING: This command makes no attempt to perform reference counting or dependency analy-
             sis. It can easily remove files required by your system. It may include unexpected files due to package tainting. Use the --files command first
             to double check.

在我的示例中,您将输入

pkgutil --unlink org.python.Python.PythonApplications-2.7
pkgutil --unlink org.python.Python.PythonDocumentation-2.7
pkgutil --unlink org.python.Python.PythonFramework-2.7
pkgutil --unlink org.python.Python.PythonProfileChanges-2.7
pkgutil --unlink org.python.Python.PythonUnixTools-2.7

或一行:

pkgutil --pkgs | grep org.python.Python | xargs -L1 pkgutil -f --unlink

重要提示:–unlink从Lion(从2014年第一季度开始,包括Lion,Mountain Lion和Mavericks)不再可用。如果涉及此说明的任何人都尝试将其与狮子一起使用,则应尝试改编本文所讲的内容:https : //wincent.com/wiki/Uninstalling_packages_(.pkg_files)_on_Mac_OS_X

If you installed it using the PKG installer, you can do:

pkgutil --pkgs

or better:

pkgutil --pkgs | grep org.python.Python

which will output something like:

org.python.Python.PythonApplications-2.7
org.python.Python.PythonDocumentation-2.7
org.python.Python.PythonFramework-2.7
org.python.Python.PythonProfileChanges-2.7
org.python.Python.PythonUnixTools-2.7

you can now select which packages you will unlink (remove).

This is the unlink documentation:

 --unlink package-id
             Unlinks (removes) each file referenced by package-id. WARNING: This command makes no attempt to perform reference counting or dependency analy-
             sis. It can easily remove files required by your system. It may include unexpected files due to package tainting. Use the --files command first
             to double check.

In my example you will type

pkgutil --unlink org.python.Python.PythonApplications-2.7
pkgutil --unlink org.python.Python.PythonDocumentation-2.7
pkgutil --unlink org.python.Python.PythonFramework-2.7
pkgutil --unlink org.python.Python.PythonProfileChanges-2.7
pkgutil --unlink org.python.Python.PythonUnixTools-2.7

or in one single line:

pkgutil --pkgs | grep org.python.Python | xargs -L1 pkgutil -f --unlink

Important: –unlink is not available anymore starting with Lion (as of Q1`2014 that would include Lion, Mountain Lion, and Mavericks). If anyone that comes to this instructions try to use it with lion, should try instead to adapt it with what this post is saying: https://wincent.com/wiki/Uninstalling_packages_(.pkg_files)_on_Mac_OS_X


回答 3

尝试使用卸载Python

brew uninstall python

不会删除本机安装了Python,而是版本安装brew

Trying to uninstall Python with

brew uninstall python

will not remove the natively installed Python but rather the version installed with brew.


回答 4

关于删除符号链接,我发现这很有用。

find /usr/local/bin -lname '../../../Library/Frameworks/Python.framework/Versions/2.7/*' -delete

In regards to deleting the symbolic links, I found this to be useful.

find /usr/local/bin -lname '../../../Library/Frameworks/Python.framework/Versions/2.7/*' -delete

回答 5

创建符号链接到最新版本

 ln -s -f /usr/local/bin/python3.8 /usr/local/bin/python

关闭并打开一个新终端

并尝试

 python --version

Create the symlink to latest version

 ln -s -f /usr/local/bin/python3.8 /usr/local/bin/python

Close and open a new terminal

and try

 python --version

回答 6

无需卸载旧的python版本。

只需安装新版本,说python-3.3.2-macosx10.6.dmg并将python的软链接更改为新安装的python3.3

使用以下命令检查默认python和python3.3的路径

“哪个python”和“哪个python3.3”

然后删除python的现有软链接并将其指向python3.3

No need to uninstall old python versions.

Just install new version say python-3.3.2-macosx10.6.dmg and change the soft link of python to newly installed python3.3

Check the path of default python and python3.3 with following commands

“which python” and “which python3.3”

then delete existing soft link of python and point it to python3.3


回答 7

OnurGüzel在他的博客文章“从OS X卸载Python包”中提供了解决方案。

您应该在终端中键入以下命令:

  1. sudo rm -rf /Library/Frameworks/Python.framework
  2. cd /usr/local/bin
  3. ls -l . | grep '../Library/Frameworks/Python.framework' | awk '{print $9}' | xargs sudo rm
  4. sudo rm -rf "/Applications/Python x.y"

    其中命令xy是安装的Python版本。根据您的问题,应该是2.7。

用Onur的话来说:

警告:此命令将删除与软件包一起安装的所有Python版本。系统提供的Python不会受到影响。

如果您从python.org安装了多个Python版本,请再次运行第四个命令,为每个要卸载的Python版本更改“ xy”。

Onur Güzel provides the solution in his blog post, “Uninstall Python Package from OS X.

You should type the following commands into the terminal:

  1. sudo rm -rf /Library/Frameworks/Python.framework
  2. cd /usr/local/bin
  3. ls -l . | grep '../Library/Frameworks/Python.framework' | awk '{print $9}' | xargs sudo rm
  4. sudo rm -rf "/Applications/Python x.y"

    where command x.y is the version of Python installed. According to your question, it should be 2.7.

In Onur’s words:

WARNING: This commands will remove all Python versions installed with packages. Python provided from the system will not be affected.

If you have more than 1 Python version installed from python.org, then run the fourth command again, changing “x.y” for each version of Python that is to be uninstalled.


回答 8

注意如果使用Homebrew安装了Python,则可以按照以下步骤操作,否则请寻找其他解决方案!


要卸载使用Homebrew安装的Python 2.7.10,可以简单地发出以下命令:

brew uninstall python

同样,如果要卸载Python 3(使用Homebrew安装),请执行以下操作:

brew uninstall --force python3

Note: If you installed Python using Homebrew, then you can follow the following steps, otherwise look for another solution!


To uninstall Python 2.7.10 which you installed using Homebrew, then you can simply issue the following command:

brew uninstall python

Similarly, if you want to uninstall Python 3 (which you installed using Homebrew):

brew uninstall --force python3

回答 9

无需卸载它或使用符号链接发疯,只需使用即可alias。升级到python 3.7.1时,我遇到了同样的问题。
只需使用安装新的python版本,brew install python然后在.bash_profile创建的别名中指向新的python版本即可;这样:alias python="/usr/local/bin/python3"然后保存并运行source ~/.bash_profile
做完了

No need to uninstall it or going crazy with symbolic links, just use an alias. I faced the same problem when upgrading to python 3.7.1.
Just install the new python version using brew install python then in your .bash_profile create an alias pointing to the new python version; like this: alias python="/usr/local/bin/python3" then save and run source ~/.bash_profile.
Done.


回答 10

如果您正在考虑手动删除Apple的默认Python 2.7,建议您立即执行以下操作:看起来Apple很快会为您完成此操作:

OSX 10.15 Catalina中不推荐使用Python 2.7

Catalina中不推荐使用Python 2.7-以及Ruby和Perl :(跳至“ 脚本语言运行时 ”>“ 不推荐使用 ”部分)

https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes

苹果将​​在OSX 10.16中删除Python 2.7

确实,如果您什么都不做,那么根据OS X版本10.16 的Mac Observer所述,Python 2.7将从您的系统中消失:

https://www.macobserver.com/analysis/macos-catalina-deprecates-unix-scripting-languages/

鉴于这一启示,我建议最好的做法是什么也不做,等待苹果为您清除。由于Apple即将为您删除它,因此似乎不值得尝试修改您的Python环境。

注意:我看到这个问题专门与OSX v 10.6.4有关,但是对于所有有兴趣从其系统中删除Python 2.7的OSX人士,无论他们运行的是哪个版本,该问题似乎都已成为一个关键点。

If you’re thinking about manually removing Apple’s default Python 2.7, I’d suggest you hang-fire and do-noting: Looks like Apple will very shortly do it for you:

Python 2.7 Deprecated in OSX 10.15 Catalina

Python 2.7- as well as Ruby & Perl- are deprecated in Catalina: (skip to section “Scripting Language Runtimes” > “Deprecations“)

https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes

Apple To Remove Python 2.7 in OSX 10.16

Indeed, if you do nothing at all, according to The Mac Observer, by OSX version 10.16, Python 2.7 will disappear from your system:

https://www.macobserver.com/analysis/macos-catalina-deprecates-unix-scripting-languages/

Given this revelation, I’d suggest the best course of action is do nothing and wait for Apple to wipe it for you. As Apple is imminently about to remove it for you, doesn’t seem worth the risk of tinkering with your Python environment.

NOTE: I see the question relates specifically to OSX v 10.6.4, but it appears this question has become a pivot-point for all OSX folks interested in removing Python 2.7 from their systems, whatever version they’re running.