vs code 配置 Anaconda3

本文介绍如何配置Anaconda的渠道源以提高下载速度,并详细说明了如何在VSCode中设置Anaconda环境,包括环境变量配置、终端配置及调试配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

历史版本

Anaconda3
Miniconda3

conda

.condarc

channels:
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/menpo/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults

pip\pip.ini

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

python3.9 兼容性好

conda install python=3.9
conda create --name py39 python=3.9 anaconda
conda activate py39

vs code

vs2019_light.json

"editor.background": "#FFFFFF",

改为

"editor.background": "#CCE8CF",

settings.json
参考https://blog.youkuaiyun.com/shaooping/article/details/122392978

 {
    "workbench.colorTheme": "Visual Studio 2019 Light",
    "python.analysis.extraPaths": [
        "C:\\ProgramData\\Anaconda3\\Lib\\site-packages",
        "C:\\Users\\cc\\AppData\\Roaming\\Python\\Python39\\site-packages"
    ],
    "workbench.iconTheme": "material-icon-theme",
    "python.autoComplete.extraPaths": [
    
    ],

    "terminal.integrated.profiles.windows": {
        "PowerShell": {
            "source": "PowerShell",
            "icon": "terminal-powershell"
        },
 
        "conda powershell terminal":{
            "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
            "args": [
          "-ExecutionPolicy" ,"ByPass", "-NoExit", "-Command","& 'C:\\ProgramData\\Anaconda3\\shell\\condabin\\conda-hook.ps1'; conda activate 'C:\\ProgramData\\Anaconda3' "
            ],
            "title":"conda powershell terminal",
        },
           
        "conda powershell 1.13":{
            "path": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
            "args": [
          "-ExecutionPolicy" ,"ByPass", "-NoExit", "-Command","& 'C:\\ProgramData\\Anaconda3\\shell\\condabin\\conda-hook.ps1'; conda activate 'C:\\Users\\cc\\.conda\\envs\\pytorch1.13' "
            ],
            "title":"conda powershell 1.13",
        }
    },
    "terminal.integrated.defaultProfile.windows": "conda powershell terminal",
    "python.terminal.activateEnvironment": true,
    "python.pythonPath": "C:\\ProgramData\\Anaconda3\\python.exe"
    //"python.pythonPath": "C:\\Users\\cc\\.conda\\envs\\pytorch1.13\\python.exe",
    "python.envFile": "${workspaceFolder}/.vscode/.env",
 
}

调试py文件时,launch.json例子

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            //"args": ["--weights", "yolov5s.pt", "--include", "torchscript", "onnx" ]
            "args": ["--data", "data/coco128.yaml", "--weights", "yolov5s.pt","--img", "640", "--device", "0", "--batch-size", "1", "--workers", "1" ]
        }
    ]
}

如果 训练时候提示 页面文件太小
修改 yolov5 utils\general.py

NUM_THREADS = 1 #min(8, max(1, os.cpu_count() - 1)) 

减小--batch-size的值
减小--workers的值

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值