脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - 在vscode中启动conda虚拟环境的思路详解

在vscode中启动conda虚拟环境的思路详解

2021-08-18 00:25weixin_53927286 Python

这篇文章主要介绍了在vscode中启动conda虚拟环境的思路详解,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

问题:cudatoolkit cudnn 通过conda 虚拟环境安装,先前已经使用virtualenv安装tf,需要在conda虚拟环境中启动外部python虚拟环境

思路:conda prompt

在vscode中启动conda虚拟环境的思路详解

即将 [虚拟环境位置] 以参数形式传入 [activate.bat]

vsocde中的设置

在vscode中启动conda虚拟环境的思路详解

添加以下语句

?
1
2
3
4
5
6
7
8
{
  "terminal.integrated.shell.windows": "c:\\windows\\system32\\cmd.exe", #选用cmd作为命令行窗口
  "terminal.integrated.shellargs.windows": [
    "/k",
    "c:\\users\\pc\\miniconda3\\scripts\\activate.bat c:\\users\\pc\\miniconda3\\envs\\tfcuda101" #此处修改为你conda虚拟环境文件夹位置
  ],
  "python.pythonpath": "c:\\users\\pc\\tensorflow2\\scripts\\python.exe", #选择virtualenv下的python路径
}

搞定,下次进入相关项目自动加载conda环境与virtualenv环境

在vscode中启动conda虚拟环境的思路详解

验证成功加载cuda库:

?
1
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

在vscode中启动conda虚拟环境的思路详解

到此这篇关于在vscode中启动conda虚拟环境的思路详解的文章就介绍到这了,更多相关vscode中启动conda虚拟环境内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/weixin_53927286/article/details/111601632

延伸 · 阅读

精彩推荐