栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Win安装conda, vscode运行python

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Win安装conda, vscode运行python

文章目录

前言一、Win10安装conda, vscode二、解决:添加环境变量path

1.win搜索“path” 三. 设置脚本执行策略总结


前言 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”

点击“环境变量”:

在系统或者用户Path添加三项conda地址
D:Anaconda3
D:Anaconda3scripts
D:Anaconda3Librarybin
具体位置可在anaconda prompt里用查:

(base) C:Userslbw>where conda
C:Userslbwanaconda3Librarybinconda.bat
C:Userslbwanaconda3scriptsconda.exe
C:Userslbwanaconda3condabinconda.bat

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

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

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

. : 无法加载文件 C:UserslbwdocumentsWindowsPowerShellprofile.ps1,
因为在此系统上禁止运行脚本。有关详细信息,请参阅
https:/go.microsoft.com/fwlink/?linkID=135170 
中的 about_Execution_Policies。
所在位置 行:1 字符: 3
+ . 'C:UserslbwdocumentsWindowsPowerShellprofile.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:Userslbw>
总结
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/740920.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号