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

vs code下运行conda环境报错

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

vs code下运行conda环境报错

在使用vs code下conda环境,运行程序会报告如下问题

conda activate base

CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If using 'conda activate' from a batch script, change your
invocation to 'CALL conda.bat activate'.

To initialize your shell, run

    $ conda init 

Currently supported shells are:
  - bash
  - cmd.exe
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

importANT: You may need to close and restart your shell after running 'conda init'.

网上查找后解决办法如下,方法二亲测可用:

方法一:

使用anaconda自带的anaconda navigator或anaconda powershell prompt,anaconda prompt来进入环境,或输入conda.bat activate “环境路径”,例如conda.batactivate"D:Anaconda3envstest"

方法二:   第一步:

打开管理员power shell,修改执行策略,执行:get-ExecutionPolicy,回复Restricted,表示状态是禁止的 

Restricted——默认的设置, 不允许任何script运行
AllSigned——只能运行经过数字证书签名的script
RemoteSigned——运行本地的script不需要数字签名,但是运行从网络上下载的script就必须要有数字签名
Unrestricted——允许所有的script运行

第二步:

执行:set-ExecutionPolicy RemoteSigned即可

 第三步:

输入:conda init

 此时:C:UsersxxxdocumentsWindowsPowerShell下会生成配置文件profile.ps1

 重启power shell或者vs code后,默认会进入conda的base环境

 恢复:

删除profile.ps1。

根据个人情况,执行set-ExecutionPolicy Restricted策略改回Restricted。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/675076.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

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

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