Python 未找到 Conda 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35246386/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 16:11:03  来源:igfitidea点击:

Conda command not found

pythonzshanacondaminiconda

提问by olivrg

I've installed Miniconda and have added the environment variable export PATH="/home/username/miniconda3/bin:$PATH"to my .bachrcand .bash_profilebut still can't run any conda commands in my terminal.

我已经安装了 Miniconda 并将环境变量添加export PATH="/home/username/miniconda3/bin:$PATH"到我的.bachrc.bash_profile但仍然无法在我的终端中运行任何 conda 命令。

Am I missing another setup? I'm using zsh by the way.

我错过了另一个设置吗?顺便说一下,我正在使用 zsh。

采纳答案by olivrg

If you're using zsh and it has not been set up to read .bashrc, you need to add the Miniconda directory to the zsh shell PATH environment variable. Add this to your .zshrc:

如果您使用的是 zsh 并且尚未设置为读取 .bashrc,则需要将 Miniconda 目录添加到 zsh shell PATH 环境变量中。将此添加到您的.zshrc

export PATH="/home/username/miniconda/bin:$PATH"

Make sure to replace/home/username/minicondawith your actual path.

确保替换/home/username/miniconda您的实际路径

Save, exit the terminal and then reopen the terminal. condacommand should work.

保存,退出终端,然后重新打开终端。conda命令应该可以工作。

回答by Kenan

If you have the PATH in your .bashrc file and are still getting

如果您的 .bashrc 文件中有 PATH 并且仍在获取

conda: command not found

Your terminal might not be looking for the bash file. Type bashin the terminal to insure you are in bash and then try: conda --version

您的终端可能不是在寻找 bash 文件。输入 bash终端,以确保你是在bash,然后尝试: conda --version

回答by dew

Maybe you need to execute "source ~/.bashrc"

也许你需要执行“source ~/.bashrc”

回答by Jeevan

I faced this issue on my mac after updating conda. Solution was to run conda mini installer on top of existing conda setup.

更新 conda 后,我在 mac 上遇到了这个问题。解决方案是在现有的 conda 设置之上运行 conda mini 安装程序。

$ curl https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3.sh
$ bash ~/miniconda3.sh -bfp ~/miniconda3

On linux, you can use:

在 linux 上,您可以使用:

$ curl https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o ~/miniconda3.sh
$ bash ~/miniconda3.sh -bfp ~/miniconda3

For other versions, you can go to https://repo.continuum.io/miniconda/

其他版本可以去https://repo.continuum.io/miniconda/

For details check: https://github.com/conda/conda/issues/1364

详情请查看:https: //github.com/conda/conda/issues/1364

回答by Taani

Make sure that you are installing the Anaconda binary that is compatible with your kernel. I was in the same situation.Turned out I have an x64_86 CPU and was trying to install a 64 bit Power 8 installer.You can find out the same for your CPU by using the following command.It gives you a basic information about a computer's software and hardware.-

确保您正在安装与您的内核兼容的 Anaconda 二进制文件。我遇到了同样的情况。结果我有一个 x64_86 CPU 并试图安装 64 位 Power 8 安装程序。您可以使用以下命令为您的 CPU 找到相同的信息。它为您提供有关计算机的基本信息软硬件。-

$ uname -a

$ uname -a

https://www.anaconda.com/download/#linux

https://www.anaconda.com/download/#linux

The page in the link above, displays 2 different types of 64-Bit installers -

上面链接中的页面显示了 2 种不同类型的 64 位安装程序 -

  • 64-Bit (x86) installer and
  • 64-Bit (Power 8) installer.
  • 64 位 (x86) 安装程序和
  • 64 位(Power 8)安装程序。

回答by Sanreet

Sometimes, if you don't restart your terminal after you have installed anaconda also, it gives this error.

有时,如果您在安装 anaconda 后也不重新启动终端,则会出现此错误。

Close your terminal window and restart it.

关闭终端窗口并重新启动它。

It worked for me now!

它现在对我有用!

回答by Golddy

I had the same issue. I just closed and reopened the terminal, and it worked. That was because I installed anaconda with the terminal open.

我遇到过同样的问题。我刚刚关闭并重新打开终端,它起作用了。那是因为我在终端打开的情况下安装了 anaconda。

回答by Gursewak Singh

Execute the following command after installing and adding to the path

安装并添加到路径后执行以下命令

source ~/.bashrc

where sourceis a bash shell built-in command that executes the content of the file passed as argument, in the current shell.

wheresource是一个 bash shell 内置命令,它在当前 shell 中执行作为参数传递的文件的内容。

It runs during boot up automatically.

它在启动期间自动运行。

回答by Seth

Maybe you should type add this to your .bashrcor .zshrc

也许你应该输入 add this to your .bashrcor.zshrc

export PATH="/anaconda3/bin":$PATH

It worked for me.

它对我有用。

回答by xgMz

For those experiencing issues after upgrading to MacOS Catalina.

对于升级到 MacOS Catalina 后遇到问题的用户。

Short version:

精简版:

# 1a) Use tool: conda-prefix-replacement - 
# Restores: Desktop -> Relocated Items -> Security -> anaconda3
curl -L https://repo.anaconda.com/pkgs/misc/cpr-exec/cpr-0.1.1-osx-64.exe -o cpr && chmod +x cpr
./cpr rehome ~/anaconda3
# or if fails
#./cpr rehome ~/anaconda3 --old-prefix /Anaconda3
source ~/anaconda3/bin/activate

# 1b) Alternatively - reintall anaconda - 
# brew cask install anaconda

# 2) conda init
conda init zsh
# or
# conda init    

Further reading - Anaconda blog postand Github discussion.

进一步阅读 - Anaconda 博客文章Github 讨论