简体   繁体   English

输出conda环境后,批处理脚本停止

[英]Batch script stops after output conda environment

I'm trying to write a batch script to export all available conda evnironments, after searching piece by piece on the internet, I came up with the following: 我试图编写一个批处理脚本以导出所有可用的conda环境,在Internet上逐段搜索后,我想到了以下内容:

@echo off

conda info --envs > conda_envs.txt

for /f "usebackq tokens=1 delims= " %%a in ("conda_envs.txt") do (
    if not %%a==# conda env export -n %%a > %%a.yml
)

The problem is that the script stops after conda info --envs > conda_envs.txt , I've tried to add call in front of both the for loop and export command, but no luck. 问题是脚本在conda info --envs > conda_envs.txt之后停止,我试图在for循环和export命令的前面添加call ,但是没有运气。 What did I do wrong? 我做错了什么?

Many thanks to npocmaka , michael_heath and SomethingDark in the comment section, I think the missing parentheses made the debug process harder. 非常感谢npocmakamichael_heathSomethingDark在注释部分,我认为缺少的括号做调试过程更难。 By adding call in front of conda does help! 通过在conda前面添加call确实有帮助! Below is a working version of the script: 以下是脚本的工作版本:

@echo off

call conda info --envs > conda_envs.txt

for /f "usebackq tokens=1 delims= " %%a in ("conda_envs.txt") do (
    if not %%a==# call conda env export -n %%a > %%a.yml
)

PS: if the second call before conda env export... is not added, this would work as well. PS:如果未添加conda env export...之前的第二个call ,则此方法同样适用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM