Windows上通过Git Bash激活Anaconda

      在Windows上配置完Anaconda后,普遍通过Anaconda Prompt激活虚拟环境并执行Python,如下图所示:

      有时需要连续执行多个python脚本时,直接在Anaconda Prompt下可以通过在以下方式,即命令间通过&&连接,不是很方便:

      Anaconda Prompt中并不支持执行shell命令,这里通过Git Bash来执行shell文件,即在shell文件中激活Anaconda并执行python脚本:

      1. 编写shell命令,文件名为run.sh,内容如下:

#! /bin/bash
source D:/ProgramFiles/Anaconda3/etc/profile.d/conda.sh
conda activate ultralytics-env

echo "train imgsz: 640"
python test_yolov8_train.py --yaml datasets/melon_new_detect/melon_new_detect.yaml --epochs 5 --task detect --imgsz 640

echo "train imgsz: 320"
python test_yolov8_train.py --yaml datasets/melon_new_detect/melon_new_detect.yaml --epochs 5 --task detect --imgsz 320

echo "test finish"

      其中etc/profile.d/conda.sh为shell脚本文件,是conda环境配置的一部分,当在Git Bash或其它shell环境中使用conda命令时,需要加载此文件。正确加载此文件后,其它命令与Anaconda Prompt中相同。

      2. 打开Git Bash Here,执行run.sh,如下图所示:

      GitHubhttps://github.com/fengbingchun/NN_Test

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值