[英]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. 非常感谢npocmaka , michael_heath和SomethingDark在注释部分,我认为缺少的括号做调试过程更难。 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.