Win安装conda, vscode运行python

文章目录

前言

Win10安装conda, vscode运行python

一、Win10安装conda, vscode

按照安装包推荐流程安装,即可从vscode运行notebook,但是不能识别conda命令,因此无法激活conda环境直接命令行跑.py

conda : The term 'conda' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct
and try again.

二、解决:添加环境变量path

1.win搜索”path”

点击”环境变量”:

Win安装conda, vscode运行python
在系统或者用户Path添加三项conda地址
D:\Anaconda3
D:\Anaconda3\Scripts
D:\Anaconda3\Library\bin
具体位置可在anaconda prompt里用查:
(base) C:\Users\lbw>where conda
C:\Users\lbw\anaconda3\Library\bin\conda.bat
C:\Users\lbw\anaconda3\Scripts\conda.exe
C:\Users\lbw\anaconda3\condabin\conda.bat

重启后powershell能识别conda命令了,可以vscode正常debug py文件,但vscode打开terminal或者直接开powershell还有一个无伤大雅的报错

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。

尝试新的跨平台 PowerShell https://aka.ms/pscore6

. : 无法加载文件 C:\Users\lbw\Documents\WindowsPowerShell\profile.ps1,
因为在此系统上禁止运行脚本。有关详细信息,请参阅
https:/go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies。
所在位置 行:1 字符: 3
+ . 'C:\Users\lbw\Documents\WindowsPowerShell\profile.ps1'
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [],PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess

三. 设置脚本执行策略

profile.ps1这个文件是conda init powershell或者conda init命令留下的脚本,用于激活conda base环境,现在系统不允许执行脚本,需要打开powershell设置下

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

现在设成RemoteSigned 模式,也可以是别的,详情见下:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.1

然后就可以正常激活conda base环境了

Windows PowerShell
版权所有 (C) Microsoft Corporation。保留所有权利。

尝试新的跨平台 PowerShell https://aka.ms/pscore6

加载个人及系统配置文件用了 857 毫秒。
(base) PS C:\Users\lbw>

总结

Original: https://blog.csdn.net/weixin_44127535/article/details/122995188
Author: 小猫佩奇
Title: Win安装conda, vscode运行python

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/771298/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球