如何设置Anaconda,使其不影响MacOS上的其他环境(如“自制python pip"和Pyenv)? [英] How to set up Anaconda so that it doesn't affect other environments like 'homebrew python pip' and Pyenv on MacOS?

查看:95
本文介绍了如何设置Anaconda,使其不影响MacOS上的其他环境(如“自制python pip"和Pyenv)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

众所周知,在MacOS上安装Anaconda可能会对其他广泛使用的软件包/环境管理器(如Homebrew,Pyenv,Virtualenv等)造成麻烦.

It is well known that Anaconda installation on macOS can cause trouble with other widely used package/environment managers like Homebrew, Pyenv, Virtualenv, etc.

我发现的大多数解决方案都是以"Anaconda为中心"的,即使用Anaconda作为主要的python管理器,并为自制软件设置 conda env .

The majority of the solutions I've found are 'Anaconda-centric', i.e. using Anaconda as the main python manager and setup conda env for homebrew etc.

但是,我正在寻找一种以自制软件为中心"的解决方案,并将Anaconda设置为一种补充.Anaconda的设置方式应使得无论何时使用 conda ,它都可以与自己的Python,自己的程序包一起使用.并保持系统的其余部分不变.

However, I am looking for a solution that's kind of 'Homebrew-centric', and setup Anaconda as a compliment. Anaconda should be set up in a way that when ever conda is used, it will work with its own Python, own packages. And leave the rest of system untouched.

这种解决方案的动机是因为,例如,当一个人的主要工作流程使用自制的Python3( python3 ),自制的pip( pip3 )和Pyenv( pyenv )和 requirement.txt .并在需要项目时偶尔使用Anaconda.

The motivation for such solution is because that, for example, when one's main work-flow use homebrew Python3 (python3), homebrew pip (pip3) and Pyenv (pyenv) with requirement.txt. And occasionally using Anaconda when a project is required.

推荐答案

我建议不要使用Anaconda,而应使用Miniconda,它仅包含Python和conda(以及一些支持包).Miniconda默认情况下并不包含Anaconda中的所有软件包,但可以全部安装(使用 conda install anaconda ).下载Miniconda 后,您可以将其安装在主目录中,位于/用户/用户名/miniconda3 .在安装过程中,系统会询问您是否要向 .bash_profile 中添加一些初始化代码.选择 yes 或(如果选择 no ),则可以运行

Rather than using Anaconda I would suggest using Miniconda, which includes only Python and conda (and a few support packages). Miniconda does not include all of the packages in Anaconda by default, but they can all be installed (with conda install anaconda). Once you download Miniconda, you can install it into your home folder at /Users/username/miniconda3. During the installation, you will be asked if you want to add some initialization code to your .bash_profile. Either choose yes or (if you chose no), then you can run

/Users/username/miniconda3/bin/conda init

将conda初始化添加到您的 .bash_profile 中.默认情况下,这将激活基本环境,因此您可以更改默认设置,以便默认情况下不激活该环境:

to add the conda initialization to your .bash_profile. By default, this will activate the base environment, so you can change the default setting so the environment is not activated by default:

conda config --set auto_activate_base false

您可能需要打开一个新终端,以便使用 conda 命令.然后,当您要使用conda环境时,可以 conda激活该环境,但是否则,conda的Python不应位于您的 PATH 上.

You'll probably need to open a new terminal so the conda command is available. Then, when you want to use a conda environment, you can conda activate that environment, but otherwise, conda's Python should not be on your PATH.

这篇关于如何设置Anaconda,使其不影响MacOS上的其他环境(如“自制python pip"和Pyenv)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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