python - Anaconda Prompt 和 Anaconda Powershell Prompt 有什么区别?

标签 python windows powershell cmd anaconda

我正在使用 Anaconda 学习 Python。早些时候我只有 Anaconda Prompt。但是最近通过

更新了 Anaconda 之后
conda update conda

我是来看Anaconda Powershell Prompt的。我在新的 Powershell Prompt 中尝试了一些命令,而我之前在 Anaconda Prompt 中尝试过这些命令。这些命令运行良好。

现在,我的问题是 Anaconda 给出 2 个命令提示的原因是什么?它们的功能或能力之间有什么区别吗?

我的操作系统是 Windows 7,Conda 版本是 4.6.12。

最佳答案

首先,对于执行 python 相关命令的所有内容(pythonipythonjupyterconda 等) .) 到运行 Python 脚本(例如 python helloworld.py),没有区别。所以不用担心 ;)

然后,顾名思义,唯一的区别是运行 conda 命令的 windows shell 环境:cmd.exe(命令提示符)与 powershell.exe


现在让我们多谈谈区别:( reference )

Briefly, the cmd.exe is a simple shell introduced with Windows NT with the same basic syntax and functionality as DOS. It has relatively limited capabilities, especially when compared to Unix/Linux shells.

And PowerShell is a modern shell implementation with all sorts of extra goodies (e.g. commands colorful highlight).

因此,在 Anaconda Powershell Prompt 中,您可以运行如下一些 powershell 命令:

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.18362.752
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> $env:PATH
C:\Users\user-name\anaconda3;C:\Users\user-name\anaconda3\Library\mingw-w64\bin;...

但是在Anaconda Prompt中,上面的命令不会被识别,你可以运行这个:

>ver

Microsoft Windows [版本 10.0.18363.815]

在幕后,Anaconda Powershell PromptAnaconda Prompt 只是调用不同命令的两个快捷方式:

%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& '%USERPROFILE%\anaconda3\shell\condabin\conda-hook.ps1' ; conda activate '%USERPROFILE%\anaconda3' "
%windir%\System32\cmd.exe "/K" %USERPROFILE%\anaconda3\Scripts\activate.bat %USERPROFILE%\anaconda3

enter image description here

关于python - Anaconda Prompt 和 Anaconda Powershell Prompt 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56656493/

相关文章:

Python Tkinter postscript 错误大小导出

python - (伪)不使用模块和时钟在 Python 中生成随机数

python - 如何在python中创建多个变量的所有可能组合

c++ - 如何通过 C++ 程序在 Windows Server 2008/2012 上初始化磁盘

c++ - 减少与 opencv 静态链接的可执行文件的大小

python - 我们可以在 Serializer 字段中填写我不需要的字段吗?

powershell - RDP进入具有特定用户名的服务器

mysql - 将SQL查询结果存储在变量中

powershell - 7zip - powershell 排除带变量的文件/文件夹

windows - cmd.exe 是 shell、终端仿真器还是两者兼而有之?