右键打开windows命令行初始化conda虚拟环境


Conda为我们提供了一种自由切换python环境的方法,但是还可以再进一步,在右键打开windows命令行时初始化conda虚拟环境,将更加方便。

将下面代码保存为cmd_here-conda.reg,然后运行即可出现在右键才按

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere]
@="CMD Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\shell\OpenCmdHere\command]
@="cmd.exe /s /k  E:\\ENV\\Miniconda3\\Scripts\\activate.bat python38"

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere]
@="CMD Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Directory\Background\shell\OpenCmdHere\command]
@="cmd.exe /s /k  E:\\ENV\\Miniconda3\\Scripts\\activate.bat python38"

[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere]
@="CMD Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\Drive\shell\OpenCmdHere\command]
@="cmd.exe /s /k  E:\\ENV\\Miniconda3\\Scripts\\activate.bat python38"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere]
@="CMD Here"
"Icon"="cmd.exe"

[HKEY_CLASSES_ROOT\LibraryFolder\background\shell\OpenCmdHere\command]
@="cmd.exe /s /k  E:\\ENV\\Miniconda3\\Scripts\\activate.bat python38"

上面的python38为需要初始化的python环境。“E:\\ENV\\Miniconda3\\Scripts\\activate.bat”要更换为conda实际安装的路径。

如果想在msys2/PowerShell中指定虚拟环境可以在conda初始化后执行 conda activate python38。

普人特福的博客cnzz&51la for wordpress,cnzz for wordpress,51la for wordpress