1. powershell无法activate conda虚拟环境
想从cmd换成powershell,发现powershell并不支持切换conda的虚拟环境。
解决方法:
打开 Powershell
- 执行命令:
conda init powershell
- 重新打开终端即可
2. 中间可能遇到的问题
1. 重启 powershell 后显示无法加载文件 C:\Users\xxx\AppData\Roaming\npm\yarn.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参阅 http://go.mic ro…
这是因为win10默认禁止执行任何powershell脚本,默认执行策略为“RESTRICTED”,可以更改为“REMOTESIGNED”
解决方法:
更改powershell的执行策略, 使用管理员权限打开powershell,执行如下命令
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
之后重新打开powershell就可以激活了,需要注意的是激活前需要加上conda命令,和cmd中不一样
2. 出现错误:CommandNotFoundError: No command ‘conda conda’
则由于该错误只在4.6.8到11中出现,其他版本应该没有什么问题。因为当前conda版本过高(我的是4.6.11),因此解决方案就是把conda降级。
执行命令:
conda install -n base conda==4.6.7
选择Yes同意后,将会安装较低版本。安装成功后关闭powershell.
再重复步骤1,以管理员身份运行powershell,即可出现前面带base的Powershell界面。问题j就解决了。
参考:解决Powershell前面没有base,无法激活虚拟环境问题 解决win10 powershell无法使用conda虚拟环境的问题 在Windows PowerShell中激活Anaconda虚拟环境