Python Windows 10 无法识别 Conda 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44597662/
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
Conda command is not recognized on Windows 10
提问by alex
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
我按照以下说明在 Windows 10 上安装了 Anaconda 4.4.0(Python 3.6 版本):https: //www.continuum.io/downloads。但是,当我打开命令提示符窗口并尝试编写
conda list
I get the
我得到
'conda' command is not recognized...
'conda' 命令无法识别...
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.
但它没有帮助。我还读到我可能需要编辑我的.bashrc
文件,但我不知道如何访问这个文件,以及我应该如何编辑它。
回答by mjoppich
In Windows, you will have to set the path to the location where you installed Anaconda3 to.
在 Windows 中,您必须设置 Anaconda3 安装位置的路径。
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\
.
对我来说,我将 anaconda3 安装到C:\Anaconda3
. 因此,您需要添加C:\Anaconda3
以及添加C:\Anaconda3\Scripts\
到您的路径变量,例如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 settings
→ edit environment variables for your account
→ select Path
variable → Edit
→ New
.
您可以通过 powershell 执行此操作(参见上文,https://msdn.microsoft.com/en-us/library/windows/desktop/bb776899( v=vs.85).aspx ),或windows
按键 → 输入environment
→ 选择从settings
→ edit environment variables for your account
→ 选择Path
变量 → Edit
→ New
。
To test it, open a new dos shell, and you should be able to use conda commands now. E.g., try conda --version
.
要测试它,请打开一个新的 dos shell,您现在应该可以使用 conda 命令了。例如,尝试conda --version
。
回答by Michael James Kali Galarnyk
When you install anaconda on windows now, it doesn't automatically add Python or Conda.
现在在 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 提示符中键入以下命令
Next, you can add Python and Condato your path by using the setx command in your command prompt.
接下来,您可以使用命令提示符中的 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
回答by Simba
Things have been changed after conda 4.6.
在 conda 4.6 之后,事情发生了变化。
Programs "Anaconda Prompt" and "Anaconda Powershell" expose the command conda
for you automatically. Find them in your startup menu.
程序“Anaconda Prompt”和“Anaconda Powershell”会conda
自动为您公开命令。在您的启动菜单中找到它们。
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.
如果您不想使用上面的提示并尝试conda
在普通cmd.exe
和 Powershell 中可用。阅读以下内容。
Expose conda
in Every Shell
暴露conda
在每个外壳中
The purpose of the following content is to make command conda
available both in cmd.exe
and Powershell on Windows.
以下内容的目的是使命令在 Windows 和 Powershell 中conda
都可用cmd.exe
。
If you have already checked "Add Anaconda to my PATH environment variable" during Anaconda installation, skip step 1.
如果您在 Anaconda 安装过程中已经勾选了“将 Anaconda 添加到我的 PATH 环境变量”,请跳过步骤 1。
If Anaconda is installed for the current use only, add
%USERPROFILE%\Anaconda3\condabin
(I meancondabin
, notScripts
) into the environment variablePATH
(the user one). If Anaconda is installed for all users on your machine, addC:\ProgramData\Anaconda3\condabin
intoPATH
.Open a newPowershell, run the following command once to initialize
conda
.conda init
如果安装 Anaconda 仅用于当前使用,请将
%USERPROFILE%\Anaconda3\condabin
(我的意思是condabin
,不是Scripts
)添加到环境变量PATH
(用户)中。如果您机器上的所有用户都安装了 Anaconda,请添加C:\ProgramData\Anaconda3\condabin
到PATH
.打开一个新的Powershell,运行以下命令一次以初始化
conda
.conda init
These steps make sure the conda
command is exposed into your cmd.exe
and Powershell.
这些步骤可确保该conda
命令暴露在您的cmd.exe
Powershell 中。
Extended Reading: conda init
from Conda 4.6
扩展阅读:conda init
来自 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.
警告:将新的\path\to\anaconda3\condabin
但不添加\path\to\anaconda3\Scripts
到您的PATH
. 这是4.6 中引入的conda
一个重大变化。
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 fromconda init –help
We're especially excited about this new way of working, because removing the need to modifyPATH
makes Conda much less disruptive to other software on your system.
Conda 4.6 添加了广泛的初始化支持,以便比以往更多的 shell 可以使用新
conda activate
命令。有关更多信息,请阅读conda init –help
我们对这种新的工作方式感到特别兴奋的输出,因为无需修改PATH
可以使 Conda 对您系统上的其他软件的破坏性大大降低。
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.
在过去,\path\to\anaconda3\Scripts
是要放入您的PATH
. 它同时conda
从“基本”环境公开命令和默认 Python。
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.
conda
4.6之后,conda
相关命令被拆分成condabin
. 这使得在不从“基本”环境激活 Python 的情况下公开 ONLY 命令conda
成为可能。
References
参考
回答by H?ken Lid
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.
适用于 Windows 的 Anaconda 安装程序的最新版本还将为“Anaconda Prompt”和“Anaconda Powershell Prompt”安装一个 Windows 启动器。如果您使用其中之一而不是常规的 windows cmd shell,则conda
默认情况下,该 shell 中应该可以使用命令、python 等。
回答by Gabriel P.
If you want to use Anaconda in regular cmd on windows you need to add several paths to your Path env variable.
如果要在 Windows 上的常规 cmd 中使用 Anaconda,则需要向 Path env 变量添加多个路径。
Those paths are (instead of Anaconda3 the folder may be Anaconda2 depending on the Anaconda versionon your PC):
这些路径是(而不是 Anaconda3,文件夹可能是 Anaconda2,具体取决于您 PC上的 Anaconda 版本):
\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
回答by Avinash Shetty
I had also faced the same problem just an hour back. I was trying to install QuTip Quantum Toolbox in PythonUnfortunately, 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.
一个小时前我也遇到了同样的问题。我试图在 Python 中安装 QuTip Quantum Toolbox不幸的是,我没有及时发现这个页面。假设您已经下载了 Anaconda 安装程序并运行它直到最后。天真地,我在 Windows 10 中打开了命令提示符,然后继续键入qutip 安装文档中给出的以下命令。
conda create -n qutip-env
conda config --append channels conda-forge
conda install qutip
conda create -n qutip-env
conda config --append 通道 conda-forge
conda 安装 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
conda 不是内部或外部命令,也不是可运行的程序或批处理文件
I went ahead and tried some other things as seen in this figures error messageFinally 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
我继续尝试了一些其他的事情,如这个数字错误消息中看到的 最后在浏览了一些 conda 网站后,我明白了如何解决这个问题。在底部的搜索栏中输入 Anaconda prompt 像这样(与 Cortana 相同的地方) Anaconda prompt
Once you are here all the conda commands will work as usual
一旦你在这里,所有的 conda 命令都会照常工作
回答by Boris
If you have installed Visual studio 2017 (profressional)
如果您已安装 Visual Studio 2017(专业版)
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:
如果您不想麻烦将它放在 Windows 上的路径环境变量中并重新启动,您可以简单地运行它:
C:\>"C:\ProgramData\Anaconda3\Scripts\conda.exe" update qt pyqt
回答by Михаил Чеботарев
case #1You should set 3 path:
case #1你应该设置 3 条路径:
%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 #2Also you can use Anaconda Promd (for Win10) instead CLI (cmd.exe)
case #2您也可以使用 Anaconda Promd(适用于 Win10)而不是 CLI(cmd.exe)
回答by user3578953
You need to add the python.exe in C://.../Anaconda3 installation file as well as C://.../Anaconda3/Scripts to PATH.
您需要将 C://.../Anaconda3 安装文件中的 python.exe 以及 C://.../Anaconda3/Scripts 添加到 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%
首先转到您的安装目录,在我的情况下,它安装在 C://Users/user/Anaconda3 和 shift+右键单击并按“在此处打开命令窗口”或者它可能是“在此处打开 powershell”,如果它是 powershell ,只需编写 cmd 并按 Enter 即可运行命令窗口。然后运行以下命令 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%"
然后转到 C://Users/user/Anaconda3/Scripts 并打开上面的命令窗口,然后运行相同的命令“setx PATH %cd%”
回答by Shashank Kumar
Even I got the same problem when I've first installed Anaconda. It said 'conda' command not found.
甚至当我第一次安装 Anaconda 时也遇到了同样的问题。它说找不到“conda”命令。
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
所以我刚刚在 PATH 变量中设置了两个值[添加了两个新的 Anaconda 路径] 系统环境变量,它们是: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.
很多人忘记添加第二个变量,即“脚本”,只需添加“conda”命令即可。