Windows 10无法识别Conda命令

问题:Windows 10无法识别Conda命令

我按照以下说明在Windows 10上安装了Anaconda 4.4.0(Python 3.6版本):https : //www.continuum.io/downloads。但是,当我打开命令提示符窗口并尝试编写时

conda list

我得到了

无法识别’conda’命令…

错误。

我试着跑

set PATH=%PATH%;C:\Users\Alex\Anaconda3

但这没有帮助。我还读到我可能需要编辑.bashrc文件,但是我不知道如何访问该文件以及如何编辑它。

I installed Anaconda 4.4.0 (Python 3.6 version) on Windows 10 by following the instructions here: https://www.continuum.io/downloads. However, when I open the Command prompt window and try to write

conda list

I get the

‘conda’ command is not recognized…

error.

I tried to run

set PATH=%PATH%;C:\Users\Alex\Anaconda3

but it didn’t help. I also read that I might need to edit my .bashrc file, but I don’t know how to access this file, and how I should edit it.


回答 0

在Windows中,您必须将路径设置为将Anaconda3安装到的位置。

对我来说,我将anaconda3安装到中C:\Anaconda3。因此,您需要在路径变量中添加C:\Anaconda3C:\Anaconda3\Scripts\,例如set PATH=%PATH%;C:\Anaconda3;C:\Anaconda3\Scripts\

您可以通过powershell进行此操作(请参见上文,https: //msdn.microsoft.com/zh-cn/library/windows/desktop/bb776899(v = vs.85).aspx ),或按一下windows键→输入environment→选择从settings→→ edit environment variables for your account选择Path变量Edit→→ New

要测试它,请打开一个新的dos外壳,您现在应该可以使用conda命令。例如,尝试conda --version

In Windows, you will have to set the path to the location where you installed Anaconda3 to.

For me, I installed anaconda3 into C:\Anaconda3. Therefore you need to add C:\Anaconda3 as well as C:\Anaconda3\Scripts\ to your path variable, e.g. set PATH=%PATH%;C:\Anaconda3;C:\Anaconda3\Scripts\.

You can do this via powershell (see above, https://msdn.microsoft.com/en-us/library/windows/desktop/bb776899(v=vs.85).aspx ), or hit the windows key → enter environment → choose from settingsedit environment variables for your account → select Path variable → EditNew.

To test it, open a new dos shell, and you should be able to use conda commands now. E.g., try conda --version.


回答 1

在conda 4.6之后,情况发生了变化

程序“ Anaconda Prompt”和“ Anaconda Powershell”会conda自动为您显示命令。在启动菜单中找到它们。

如果您不想使用上面的提示,请尝试conda使用普通cmd.exe和Powershell。阅读以下内容。


暴露conda在每个shell

以下内容的目的是使命令在Windows condacmd.exe和Powershell中均可用。

如果在Anaconda安装过程中已选中“将Anaconda添加到我的PATH环境变量”,请跳过步骤1。

  1. 如果Anaconda仅安装用于当前用途,则将%USERPROFILE%\Anaconda3\condabin(我的意思是condabin,不是Scripts)添加到环境变量PATH(用户一个)中。如果您的计算机上的所有用户都安装了Anaconda,请添加C:\ProgramData\Anaconda3\condabin到中PATH

    如何在Windows上设置系统环境变量?

  2. 打开一个新的 Powershell,一次运行以下命令进行初始化conda

    conda init

这些步骤确保conda命令显示在您的cmd.exePowershell中。


扩展阅读:conda init来自Conda 4.6

警告:将新内容添加到您的中,\path\to\anaconda3\condabin但不要添加。这是4.6中引入的重大更改\path\to\anaconda3\ScriptsPATHconda

激活脚本初始化fron conda4.6发布日志

Conda 4.6添加了广泛的初始化支持,因此可以使用新conda activate命令的外壳比以前更多。有关更多信息,请阅读的输出。conda init –help对于这种新的工作方式,我们特别感到兴奋,因为消除了修改需求,PATH使Conda对系统上其他软件的破坏性大大降低。

在过去,这\path\to\anaconda3\Scripts是您的必备条件PATH。它conda同时在“基本”环境中公开命令和默认Python。

conda4.6 之后,conda相关命令分为condabin。这样就可以公开仅命令,conda而无需从“基本”环境中激活Python。

参考文献

Things have been changed after conda 4.6.

Programs “Anaconda Prompt” and “Anaconda Powershell” expose the command conda for you automatically. Find them in your startup menu.

If you don’t wanna use the prompts above and try to make conda available in a normal cmd.exe and a Powershell. Read the following content.


Expose conda in Every Shell

The purpose of the following content is to make command conda available both in cmd.exe and Powershell on Windows.

If you have already checked “Add Anaconda to my PATH environment variable” during Anaconda installation, skip step 1.

  1. If Anaconda is installed for the current use only, add %USERPROFILE%\Anaconda3\condabin (I mean condabin, not Scripts) into the environment variable PATH (the user one). If Anaconda is installed for all users on your machine, add C:\ProgramData\Anaconda3\condabin into PATH.

    How do I set system environment variables on Windows?

  2. Open a new Powershell, run the following command once to initialize conda.

    conda init
    

These steps make sure the conda command is exposed into your cmd.exe and Powershell.


Extended Reading: conda init from Conda 4.6

Caveat: Add the new \path\to\anaconda3\condabin but not \path\to\anaconda3\Scripts into your PATH. This is a big change introduced in conda 4.6.

Activation script initialization fron conda 4.6 release log

Conda 4.6 adds extensive initialization support so that more shells than ever before can use the new conda activate command. For more information, read the output from conda init –help We’re especially excited about this new way of working, because removing the need to modify PATH makes Conda much less disruptive to other software on your system.

In the old days, \path\to\anaconda3\Scripts is the one to be put into your PATH. It exposes command conda and the default Python from “base” environment at the same time.

After conda 4.6, conda related commands are separated into condabin. This makes it possible to expose ONLY command conda without activating the Python from “base” environment.

References


回答 2

现在在Windows上安装anaconda时,它不会自动添加Python或Conda。

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

接下来,您可以在命令提示符下使用setx命令将Python和Conda添加到路径中。

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

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

When you install anaconda on windows now, it doesn’t automatically add Python or Conda.

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

Next, you can add Python and Conda to your path by using the setx command in your command prompt.

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

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


回答 3

用于Windows的最新版本的Anaconda安装程序还将为“ Anaconda Prompt”和“ Anaconda Powershell Prompt”安装Windows启动器。如果您使用其中之一而不是常规的Windows cmd Shell,则conda默认情况下,此Shell中应使用命令python等。

The newest version of the Anaconda installer for Windows will also install a windows launcher for “Anaconda Prompt” and “Anaconda Powershell Prompt”. If you use one of those instead of the regular windows cmd shell, the conda command, python etc. should be available by default in this shell.


回答 4

如果要在Windows的常规cmd中使用Anaconda,则需要向Path env变量添加几个路径。

这些路径是(根据 PC 上的Anaconda版本文件夹可能是Anaconda2而不是Anaconda2):

\Users\YOUR_USER\Anaconda3
\Users\YOUR_USER\Anaconda3\Library\mingw-w64\bin
\Users\YOUR_USER\Anaconda3\Library\usr\bin
\Users\YOUR_USER\Anaconda3\Library\bin
\Users\YOUR_USER\Anaconda3\Scripts
\Users\YOUR_USER\Anaconda3\bin

If you want to use Anaconda in regular cmd on windows you need to add several paths to your Path env variable.

Those paths are (instead of Anaconda3 the folder may be Anaconda2 depending on the Anaconda version on your PC):

\Users\YOUR_USER\Anaconda3
\Users\YOUR_USER\Anaconda3\Library\mingw-w64\bin
\Users\YOUR_USER\Anaconda3\Library\usr\bin
\Users\YOUR_USER\Anaconda3\Library\bin
\Users\YOUR_USER\Anaconda3\Scripts
\Users\YOUR_USER\Anaconda3\bin

回答 5

一个小时前,我也遇到了同样的问题。我试图用Python安装QuTip Quantum Toolbox 不幸的是,我没有及时发现该页面。假设您已经下载了Anaconda安装程序并运行到最后。天真地,我在Windows 10中打开了命令提示符,然后继续输入qutip installation docs中给出的以下命令。

康达创建-n qutip-env

conda配置-添加通道conda-forge

康达安装qutip

但是,当我键入第一行时,我得到以下响应

不能将conda识别为内部或外部命令,可操作程序或批处理文件

错误消息

我继续尝试了一些其他操作,如该数字 错误消息所示。 最后,在访问了多个conda网站之后,我了解了如何解决此问题。在底部的搜索栏中输入Anaconda提示符,如下所示(在同一位置您赞美Cortana) Anaconda提示符

一旦您在这里,所有的conda命令将照常工作

I had also faced the same problem just an hour back. I was trying to install QuTip Quantum Toolbox in Python Unfortunately, I didn’t stumble onto this page in time. Say you have downloaded Anaconda installer and run it until the end. Naively, I opened the command prompt in windows 10 and proceded to type the following commands as given in the qutip installation docs.

conda create -n qutip-env

conda config –append channels conda-forge

conda install qutip

But as soon as I typed the first line I got the following response

conda is not recognized as an internal or external command, operable program or batch file

error messsage

I went ahead and tried some other things as seen in this figures error message Finally after going through a number conda websites, I understood how one fixes this problem. Type Anaconda prompt in the search bar at the bottom like this (same place where you hail Cortana) Anaconda prompt

Once you are here all the conda commands will work as usual


回答 6

如果您已安装Visual Studio 2017(专业版)

安装位置:

C:\ProgramData\Anaconda3\Scripts

如果您不希望将其放入Windows的path环境变量中并重新启动,可以通过以下简单方式运行它:

C:\>"C:\ProgramData\Anaconda3\Scripts\conda.exe" update qt pyqt

If you have installed Visual studio 2017 (profressional)

The install location:

C:\ProgramData\Anaconda3\Scripts

If you do not want the hassle of putting this in your path environment variable on windows and restarting you can run it by simply:

C:\>"C:\ProgramData\Anaconda3\Scripts\conda.exe" update qt pyqt

回答 7

甚至在我初次安装Anaconda时遇到了同样的问题。它说找不到“ conda”命令。

因此,我只设置了两个值[在PATH变量中添加了Anaconda的两个新路径]系统环境变量:C:\ Users \ mshas \ Anaconda2 \和C:\ Users \ mshas \ Anaconda2 \ Scripts

很多人忘记添加第二个变量“ Scripts”,而只需添加“ conda”命令即可。

Even I got the same problem when I’ve first installed Anaconda. It said ‘conda’ command not found.

So I’ve just setup two values[added two new paths of Anaconda] system environment variables in the PATH variable which are: C:\Users\mshas\Anaconda2\ & C:\Users\mshas\Anaconda2\Scripts

Lot of people forgot to add the second variable which is “Scripts” just add that then ‘conda’ command works.


回答 8

您需要将C://…/Anaconda3安装文件中的python.exe以及C://…/Anaconda3/Scripts添加到PATH。

首先转到您的安装目录,在我的情况下,它安装在C:// Users / user / Anaconda3中,并按住Shift键并单击鼠标右键,然后按“在此处打开命令窗口”,或者如果是powershell,则可能是“在此处打开powershell” ,只需编写cmd并按Enter键即可运行命令窗口。然后运行以下命令setx PATH%cd%

然后转到C:// Users / user / Anaconda3 / Scripts并在上面打开命令窗口,然后运行相同的命令“ setx PATH%cd%”

You need to add the python.exe in C://…/Anaconda3 installation file as well as C://…/Anaconda3/Scripts to PATH.

First go to your installation directory, in my case it is installed in C://Users/user/Anaconda3 and shift+right click and press “Open command window here” or it might be “Open powershell here”, if it is powershell, just write cmd and hit enter to run command window. Then run the following command setx PATH %cd%

Then go to C://Users/user/Anaconda3/Scripts and open the command window there as above, then run the same command “setx PATH %cd%”


回答 9

情况#1 您应设置3条路径:

%ANACONDAPATH%;
%ANACONDAPATH%\Scripts;
%ANACONDAPATH%\Library\bin;

它将解决问题:

C:\WINDOWS\system32>conda update conda
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/msys2/noarch/repodata.json.bz2>
Elapsed: -
...

案例2 您还可以使用Anaconda Promd(用于Win10)代替CLI(cmd.exe)

case #1 You should set 3 path:

%ANACONDAPATH%;
%ANACONDAPATH%\Scripts;
%ANACONDAPATH%\Library\bin;

It will solve problem:

C:\WINDOWS\system32>conda update conda
Solving environment: failed

CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://repo.anaconda.com/pkgs/msys2/noarch/repodata.json.bz2>
Elapsed: -
...

case #2 Also you can use Anaconda Promd (for Win10) instead CLI (cmd.exe)


回答 10

为了防止SSL出现其他问题,您应该将所有这些都添加到Path中:

 SETX PATH "%PATH%;C:\<path>\Anaconda3;C:\<path>\Anaconda3\Scripts;C:\<path>\Anaconda3\Library\bin"

请求(由SSLError引起(“由于SSL模块不可用,无法连接到HTTPS URL。”)PyCharm请求网站中的错误

To prevent having further issues with SSL you should add all those to Path :

 SETX PATH "%PATH%;C:\<path>\Anaconda3;C:\<path>\Anaconda3\Scripts;C:\<path>\Anaconda3\Library\bin"

Requests (Caused by SSLError(“Can’t connect to HTTPS URL because the SSL module is not available.”) Error in PyCharm requesting website