首页 > 解决方案 > /bin/bash: conda: 找不到命令

问题描述

!conda --version
/bin/bash: conda: command not found

我已经安装了 miniconda 并选择了自动添加环境变量,但我仍然无法使用它们。我正在使用谷歌 Colab。

WARNING:
You currently have a PYTHONPATH environment variable set. This may cause
unexpected behavior when running the Python interpreter in Miniconda3.
For best results, please verify that your PYTHONPATH only points to
directories of packages that are compatible with the Python interpreter
in Miniconda3: /root/miniconda3

Do you wish the installer to initialize Miniconda3
in your /root/.bashrc ? [yes|no]
[no] >>> yes

Initializing Miniconda3 in /root/.bashrc
A backup will be made to: /root/.bashrc-miniconda3.bak


For this change to become active, you have to open a new terminal.

Thank you for installing Miniconda3!

标签: condagoogle-colaboratory

解决方案


康达init

尝试手动运行 Conda 的初始化方法。首先检查它会做什么:

/root/miniconda3/bin/conda init --dry-run -vv

这应该生成一个diff输出,以及它正在检查的文件列表,用modified或标记no change。如果建议的更改看起来不错,那么继续运行它而不使用--dry-run.

一旦你打开一个新的 shell,或者源它改变的任何文件(例如,),事情应该会正常工作.bashrc


不要编辑PATH(在 Conda >=4.4 中)

请注意,此建议适用于最新版本的 Conda(v4.4+,AFAIK)。对于旧版本,过去建议直接将bin目录添加到PATH,但现在不鼓励这样做(请参阅Conda v4.4 发行说明)。


推荐阅读