From 9622b319fce9778fd7cc4f6ba1c326f4c6d7c37d Mon Sep 17 00:00:00 2001 From: Jean-Yves TINEVEZ Date: Sun, 10 Mar 2024 11:39:08 +0100 Subject: [PATCH] Activate conda env if it runs in Windows This fix was proposed originally by @msphan, but the master diverged. I include it in this commit by cimply copy-pasting the relevant lines. We could reproduce the bug separately, and in my case using omnipose. The fix works for both of us. Signed-off-by: Minh-Son PHAN --- .../trackmate/cellpose/AbstractCellposeSettings.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/fiji/plugin/trackmate/cellpose/AbstractCellposeSettings.java b/src/main/java/fiji/plugin/trackmate/cellpose/AbstractCellposeSettings.java index a17885bf..4eb60be5 100644 --- a/src/main/java/fiji/plugin/trackmate/cellpose/AbstractCellposeSettings.java +++ b/src/main/java/fiji/plugin/trackmate/cellpose/AbstractCellposeSettings.java @@ -1,9 +1,12 @@ package fiji.plugin.trackmate.cellpose; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; +import ij.IJ; + public abstract class AbstractCellposeSettings { @@ -88,6 +91,14 @@ public List< String > toCmdLine( final String imagesDir ) final String lastItem = split[ split.length - 1 ]; if ( lastItem.toLowerCase().startsWith( "python" ) ) { + // Activate conda env if it runs in Windows. + if ( IJ.isWindows() ) + { + final String envname = split[ split.length - 2 ]; + cmd.addAll( Arrays.asList( "cmd.exe", "/c", "conda", "activate", envname ) ); + cmd.add( "&" ); + } + // Calling Cellpose from python. cmd.add( executablePath ); cmd.add( "-m" );