VScode和Anaconda配置使用Python环境 您所在的位置:网站首页 vscode和anaconda VScode和Anaconda配置使用Python环境

VScode和Anaconda配置使用Python环境

2022-03-24 04:57| 来源: 网络整理| 查看: 265

1.安装Anaconda和VScode

此步骤略过。

2.VSCode配置

1.使用快捷键“Shift+Ctrl+X”,打开VSCode,在扩展一栏搜索并点击安装Python插件。 在这里插入图片描述 在这里插入图片描述 2.点击安装之后,配置Python路径 依次选择:文件–>首选项–>设置,在右边搜索栏搜索python.pythonPath,将中间的搜索结果复制粘贴到右边【用户设置】,修改引号中间的地址为你的Anaconda安装的地址,记得后面追加一个python.exe,保持这个json文件后它会自动覆盖中间所显示的默认设置。

在这里插入图片描述 当创建一个.py文件时,进行python代码测试时,不显示对应的结果。 问题显示:

PS D:\vs_file\markdown_file> 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'.

解决方法:

conda init cmd.exe

选中代码部分,按住“Shift+Enter”,就可以显示运行结果。

3.测试Python环境是否可以运行 测试代码:

import torch x = torch.empty(5, 3) print(x)

运行结果:

tensor([[4.1327e-39, 8.9082e-39, 9.8265e-39], [9.4592e-39, 1.0561e-38, 1.0653e-38], [1.0469e-38, 9.5510e-39, 1.0286e-38], [1.0194e-38, 9.6429e-39, 9.2755e-39], [8.4490e-39, 1.0469e-38, 9.3674e-39]])


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有