使用 Anaconda 安装 Python 环境
Installing a Python environment with Anaconda
我刚刚尝试使用终端使用 Home-brew 安装 Anaconda,并收到以下消息:
L-MBP:agda-stdlib le$ brew install conda
Updating Homebrew...
Error: No available formula with the name "conda"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
L-MBP:agda-stdlib le$ brew install anaconda
Error: No available formula with the name "anaconda"
Found a cask named "anaconda" instead. Try
brew cask install anaconda``
L-MBP:agda-stdlib le$ brew cask install anaconda
==> Caveats
Cask anaconda installs files under /usr/local. The presence of such
files can cause warnings when running `brew doctor`, which is considered
to be a bug in Homebrew Cask.
...
installation finished.
==> Changing ownership of paths required by anaconda; your password may be necessary
anaconda was successfully installed!
L-MBP:agda-stdlib le$ conda create --name snakes python=3.7.2
-bash: conda: command not found
L-MBP:agda-stdlib le$ conda -bash: conda: command not found
当我尝试打开 anaconda 并尝试创建 Python 环境时,我收到消息“'command not found'”。
有什么问题?
通过 Homebrew 安装 anaconda
通过 brew cask
通过执行
安装 anaconda
➜ brew cask install anaconda (or)
➜ brew install --cask anaconda [Newer versions of Homebrew]
.
.
.
PREFIX=/usr/local/anaconda3
.
.
.
anaconda was successfully installed!
让我们运行 jupyter notebook
尝试在您的终端中执行 jupyter notebook
。
这行不通……为什么?因为我们的 shell 不知道 anaconda 文件夹在哪里,所以让我们将该文件夹添加到我们的 shell 路径。
设置环境路径。
在 ~/.zshrc
文件顶部插入一行,因为当您尝试在终端上执行 python 时,它会先搜索文件夹 /usr/local/anaconda3/bin,然后再搜索默认操作系统路径,这意味着你可以执行 jupyter notebook 和 python .
export PATH="/usr/local/anaconda3/bin:$PATH"
重新启动终端或使用 source ~/.zshrc
重新加载您的 shell 环境并执行 jupyter notebook 输出将如下所示
使用 Homebrew 安装 Anaconda:
- 转到您的终端并输入
brew cask install anaconda
,然后点击 return。
- 确保 anaconda 在您的
PATH
中。您需要打开终端的配置文件(通常是 mac 上的 ~/.zshrc
)并找到以 PATH=
开头的行。在附近添加一行:export PATH="/usr/local/anaconda3/bin:$PATH"
。这是 Homebrew 安装 Anaconda 的地方。
- 退出并重新启动您的终端。这是确保加载新配置的最简单方法。
- 测试它是否适用于
which conda
。
您现在应该可以使用 conda
命令了。
编辑:正如本主题中的类似帖子所指出的,conda activate
的工作方式因版本而异。如果以上方法没有给您足够好的结果,请尝试使用以下方法启用 conda activate
和 conda deactivate
命令。
对于bash或zsh,把
export PATH="/opt/conda/bin:$PATH"
在您的 ~/.zshrc 文件中将您的基本环境放在 PATH 上,但不一定实际激活该环境。尝试删除该行并将其替换为
. ~/Anaconda3/etc/profile.d/conda.sh
conda activate base
按照 official Anaconda 4.4.0 release notes 中的建议。
将 ~/Anaconda3
替换为你安装 Anaconda 的路径,如果你把它放在其他地方。
运行 conda activate base
将基础环境放在 PATH 上,并允许您访问基础环境中的可执行文件。
其他资源:
Anaconda 和 JetBrains 建立了合作伙伴关系。您可以使用 Homebrew 下载 PyCharm IDE:brew cask install pycharm-ce-with-anaconda-plugin
。 Here is the link to the tap.
-
-
-
我刚刚尝试使用终端使用 Home-brew 安装 Anaconda,并收到以下消息:
L-MBP:agda-stdlib le$ brew install conda
Updating Homebrew...
Error: No available formula with the name "conda"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
L-MBP:agda-stdlib le$ brew install anaconda
Error: No available formula with the name "anaconda"
Found a cask named "anaconda" instead. Try
brew cask install anaconda``
L-MBP:agda-stdlib le$ brew cask install anaconda
==> Caveats
Cask anaconda installs files under /usr/local. The presence of such
files can cause warnings when running `brew doctor`, which is considered
to be a bug in Homebrew Cask.
...
installation finished.
==> Changing ownership of paths required by anaconda; your password may be necessary
anaconda was successfully installed!
L-MBP:agda-stdlib le$ conda create --name snakes python=3.7.2
-bash: conda: command not found
L-MBP:agda-stdlib le$ conda -bash: conda: command not found
当我尝试打开 anaconda 并尝试创建 Python 环境时,我收到消息“'command not found'”。
有什么问题?
通过 Homebrew 安装 anaconda
通过 brew cask
通过执行
➜ brew cask install anaconda (or)
➜ brew install --cask anaconda [Newer versions of Homebrew]
.
.
.
PREFIX=/usr/local/anaconda3
.
.
.
anaconda was successfully installed!
让我们运行 jupyter notebook
尝试在您的终端中执行 jupyter notebook
。
这行不通……为什么?因为我们的 shell 不知道 anaconda 文件夹在哪里,所以让我们将该文件夹添加到我们的 shell 路径。
设置环境路径。
在 ~/.zshrc
文件顶部插入一行,因为当您尝试在终端上执行 python 时,它会先搜索文件夹 /usr/local/anaconda3/bin,然后再搜索默认操作系统路径,这意味着你可以执行 jupyter notebook 和 python .
export PATH="/usr/local/anaconda3/bin:$PATH"
重新启动终端或使用 source ~/.zshrc
重新加载您的 shell 环境并执行 jupyter notebook 输出将如下所示
使用 Homebrew 安装 Anaconda:
- 转到您的终端并输入
brew cask install anaconda
,然后点击 return。 - 确保 anaconda 在您的
PATH
中。您需要打开终端的配置文件(通常是 mac 上的~/.zshrc
)并找到以PATH=
开头的行。在附近添加一行:export PATH="/usr/local/anaconda3/bin:$PATH"
。这是 Homebrew 安装 Anaconda 的地方。 - 退出并重新启动您的终端。这是确保加载新配置的最简单方法。
- 测试它是否适用于
which conda
。
您现在应该可以使用 conda
命令了。
编辑:正如本主题中的类似帖子所指出的,conda activate
的工作方式因版本而异。如果以上方法没有给您足够好的结果,请尝试使用以下方法启用 conda activate
和 conda deactivate
命令。
对于bash或zsh,把
export PATH="/opt/conda/bin:$PATH"
在您的 ~/.zshrc 文件中将您的基本环境放在 PATH 上,但不一定实际激活该环境。尝试删除该行并将其替换为
. ~/Anaconda3/etc/profile.d/conda.sh
conda activate base
按照 official Anaconda 4.4.0 release notes 中的建议。
将 ~/Anaconda3
替换为你安装 Anaconda 的路径,如果你把它放在其他地方。
运行 conda activate base
将基础环境放在 PATH 上,并允许您访问基础环境中的可执行文件。
其他资源:
Anaconda 和 JetBrains 建立了合作伙伴关系。您可以使用 Homebrew 下载 PyCharm IDE:
brew cask install pycharm-ce-with-anaconda-plugin
。 Here is the link to the tap.