Windows 环境 visual studio code 配置 Anaconda + Python 开发环境

使用 visual studio code 进行 python 开发时,有时需要指定为在某个 anaconda 环境中运行

1. 安装 Anaconda 后,尝试 Powershell 运行 conda --version,若提示无法将“conda”项识别为 cmdlet、函数、脚本文件或可运行程序的名称,需要在环境变量中添加 conda 路径

    默认路径在:C:UsersAlananaconda3Scripts

    添加 conda 路径后,重启 Powershell 执行 conda --version,若提示需要执行  conda init <shellname>,则执行:conda init powershell 并重启

2. 再次启动 Powershell 红色文字提示错误:

    无法加载文件 c:usersalandocumentswindowspowershellprofile.ps1,因为在此系统上禁止运行脚本

    需要在 Powershell 中执行 set-executionpolicy remotesigned 并重启

3. 在 vs code 中,在软件左下角选择 python 环境,选择对应的 conda env 的 python 即可

原文地址:https://www.cnblogs.com/462079558/p/15532581.html