python - 使用 Anaconda 安装 Python 环境

标签 python anaconda homebrew

我刚刚尝试使用终端使用 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 环境时,我收到消息“找不到命令”。

问题是什么?

最佳答案

通过 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,输出将是这样的

terminal

引用:Install anaconda on macOS with Homebrew

关于python - 使用 Anaconda 安装 Python 环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62611798/

相关文章:

php - 如何使用brew安装的php?

ruby - UTF-8 和 'split' 的 Homebrew 和 ruby​​ 错误

python - 字典的字节列表转换为DataFrame

serialization - 如何在 IPython 中安装 dill?

python - 即使使用全新的 Anaconda 安装,使用依赖于 scipy 的包也会引发 ImportError(DLL 加载失败)

python - 在 python3、Anaconda 中导入 cv2 时出错

macos - 尝试更新brew包管理器时出错

python - 在 web.py 中获取自定义 HTTP 请求 header ?

php - 在 PHP 中处理 Python 异常/错误

python - 如何使用 Python 进行调试