Python 为什么 Anaconda 无法识别 conda 命令?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28612500/
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 03:30:46  来源:igfitidea点击:

Why Anaconda does not recognize conda command?

pythonanacondaconda

提问by

I installed the latest version of Anaconda. Now I want to install OpenCV within it. When I type:

我安装了最新版本的 Anaconda。现在我想在其中安装 OpenCV。当我输入:

conda install -c https://conda.binstar.org/anaconda opencv

I get this message error: "conda is not recognized as internal command ..." (sorry, I try to translate from French because my OS is in French)

我收到此消息错误:“ conda 未被识别为内部命令...”(抱歉,我尝试从法语翻译,因为我的操作系统是法语)

The problem is that conda comes with Anaconda, so I wonder why lauching Anaconda and type the above command does not work ?

问题是 conda 随 Anaconda 一起提供,所以我想知道为什么启动 Anaconda 并键入上述命令不起作用?

回答by Chironian

You probably need to update your PATHvariable to include where you have installed Anaconda.

您可能需要更新PATH变量以包含安装 Anaconda 的位置。

See https://github.com/ContinuumIO/anaconda-issues/issues/41for a similar issue.

有关类似问题,请参阅https://github.com/ContinuumIO/anaconda-issues/issues/41

回答by user3344236

I suspect you forget to export PATH, anaconda/bin must be added in your $PATH. (Linux, OSX common problem). On Windows make sure you run install and commands as administrator.

我怀疑您忘记导出 PATH,必须在 $PATH 中添加 anaconda/bin。(Linux、OSX 常见问题)。在 Windows 上,确保以管理员身份运行安装和命令。

回答by Johan

If this problem persists, you may want to check all path values in the PATH variable (under Control Panel\System and Security\System\Advanced System Settings). It might be that some other path is invalid or contains an illegal character.

如果此问题仍然存在,您可能需要检查 PATH 变量(在 下Control Panel\System and Security\System\Advanced System Settings)中的所有路径值。可能是其他路径无效或包含非法字符。

Today, I had the same problem and found a double quote in a different path value in the PATH variable. All paths after that (including a fresly installed conda) were not usable. Removing the double quote solved the problem.

今天,我遇到了同样的问题,在 PATH 变量的不同路径值中发现了双引号。之后的所有路径(包括新安装的 conda)都不可用。删除双引号解决了问题。

回答by scdavis50

Same problem with Anaconda running on Ubuntu 15.10. I closed the terminal and opened a new window and it worked fine.

在 Ubuntu 15.10 上运行的 Anaconda 也有同样的问题。我关闭了终端并打开了一个新窗口,它运行良好。

回答by Eskapp

Faced the same problem running on Windows 10 and using the Windows cmd.

在 Windows 10 上运行并使用 Windows cmd 时遇到了同样的问题。

Solved it by running the following command in the Anaconda Prompt which comes with Anaconda3 (as administrator):

通过在 Anaconda3 附带的 Anaconda Prompt 中运行以下命令来解决它(以管理员身份):

conda install -c menpo opencv3=3.1.0

Command found on the official website: https://anaconda.org/menpo/opencv3

命令在官网找到:https: //anaconda.org/menpo/opencv3

回答by Anubhav

Try restarting the terminal, I had the same issue, worked after restarting the terminal.

尝试重新启动终端,我遇到了同样的问题,在重新启动终端后工作。

回答by yellow01

For Windows

对于 Windows

Go to Control Panel\System and Security\System\Advanced System Settingsthen look for Environment Variables.

Control Panel\System and Security\System\Advanced System Settings然后寻找Environment Variables

Your user variables should contain Path=Path\to\Anaconda3\Scripts.

您的用户变量应包含Path=Path\to\Anaconda3\Scripts.

You need to figure where your Anaconda3folder is (i.e. the path to this folder) . Mine was in C:\Users.

你需要弄清楚你的Anaconda3文件夹在哪里(即这个文件夹的路径)。我的是在C:\Users

For Linux

对于 Linux

You need to add condato PATH. To do so, type:

您需要添加condaPATH. 为此,请键入:

export PATH=/path/to/anaconda3/bin:$PATH.

export PATH=/path/to/anaconda3/bin:$PATH.

Same thing, you need to figure the path to anaconda3folder (Usually, the path is stored in $HOME)

同样的事情,你需要找出anaconda3文件夹的路径(通常,路径存储在$HOME

If you don't want to do this everytime you start a session, you can also add condato PATHin your .bashrcfile:

如果您不想在每次开始会话时都这样做,您还conda可以PATH.bashrc文件中添加:

echo 'export PATH=/path/to/anaconda3/bin:$PATH' >> ~/.bashrc

echo 'export PATH=/path/to/anaconda3/bin:$PATH' >> ~/.bashrc

回答by Ali Ismayilov

I had a similar problem. I searched conda.exeand I found it on Scripts folder. So, In Anaconda3 you need to add two variables to PATH. The first is Anaconda_folder_pathand the second is Anaconda_folder_path\Scripts

我有一个类似的问题。我搜索conda.exe并在 Scripts 文件夹中找到了它。因此,在 Anaconda3 中,您需要将两个变量添加到PATH. 第一个是Anaconda_folder_path,第二个是Anaconda_folder_path\Scripts

回答by wrightwx

In Windows 10, I went to the folder where Anaconda is stored. In my case it is in \Anaconda3 folder as a shortcut to open a command prompt window, called "Anaconda Prompt". Open that and execute the command there.

在 Windows 10 中,我转到存储 Anaconda 的文件夹。就我而言,它位于 \Anaconda3 文件夹中,作为打开名为“Anaconda Prompt”的命令提示符窗口的快捷方式。打开它并在此处执行命令t

回答by Michael James Kali Galarnyk

When you install anaconda on windows now, it doesn't automatically add Python or Conda to your path so you have to add it yourself.

当您现在在 Windows 上安装 anaconda 时,它不会自动将 Python 或 Conda 添加到您的路径中,因此您必须自己添加。

If you don't know where your conda and/or python is, you type the following commands into your anaconda prompt

如果您不知道 conda 和/或 python 在哪里,请在 anaconda 提示符中键入以下命令

enter image description here

在此处输入图片说明

Next, you can add Python and Condato your path by using the setx command in your command prompt. enter image description here

接下来,您可以使用命令提示符中的 setx 命令将Python 和 Conda添加到您的路径中。 在此处输入图片说明

Next close that command prompt and open a new one. Congrats you can now use conda and python

接下来关闭该命令提示符并打开一个新的。恭喜你现在可以使用 conda 和 python

Source: https://medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444

来源:https: //medium.com/@GalarnykMichael/install-python-on-windows-anaconda-c63c7c3d1444