Forked from maximlt/run_python_script_in_conda_env.bat
          
        
    
          Created
          April 1, 2024 06:23 
        
      - 
      
 - 
        
Save kerm1t/88916958b75b461404c02d45de4ff785 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
maximlt revised this gist
Jun 17, 2020 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,15 +19,15 @@ rem Using call is required here, see: https://stackoverflow.com/questions/246781 call %CONDAPATH%\Scripts\activate.bat %ENVPATH% rem Run a python script in that environment python script.py rem Deactivate the environment call conda deactivate rem If conda is directly available from the command line then the following code works. rem call activate someenv rem python script.py rem conda deactivate rem One could also use the conda run command rem conda run -n someenv python script.py  - 
        
maximlt revised this gist
Jun 17, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,7 +26,7 @@ call conda deactivate rem If conda is directly available from the command line then the following code works. rem call activate someenv rem python -c "import sys; print('Executed by: ', sys.executable)" rem conda deactivate rem One could also use the conda run command  - 
        
maximlt revised this gist
Jun 17, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ rem - cmd.exe to be initialized with conda init rem Define here the path to your conda installation set CONDAPATH=C:\ProgramData\Miniconda3 rem Define here the name of the environment set ENVNAME=someenv rem The following command activates the base environment. rem call C:\ProgramData\Miniconda3\Scripts\activate.bat C:\ProgramData\Miniconda3 @@ -25,9 +25,9 @@ rem Deactivate the environment call conda deactivate rem If conda is directly available from the command line then the following code works. rem call activate someenv python -c "import sys; print('Executed by: ', sys.executable)" rem conda deactivate rem One could also use the conda run command rem conda run -n someenv python -c "import sys; print('Executed by: ', sys.executable)"  - 
        
maximlt created this gist
Jun 17, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ @echo OFF rem How to run a Python script in a given conda environment from a batch file. rem It doesn't require: rem - conda to be in the PATH rem - cmd.exe to be initialized with conda init rem Define here the path to your conda installation set CONDAPATH=C:\ProgramData\Miniconda3 rem Define here the name of the environment set ENVNAME=mikesdk rem The following command activates the base environment. rem call C:\ProgramData\Miniconda3\Scripts\activate.bat C:\ProgramData\Miniconda3 if %ENVNAME%==base (set ENVPATH=%CONDAPATH%) else (set ENVPATH=%CONDAPATH%\envs\%ENVNAME%) rem Activate the conda environment rem Using call is required here, see: https://stackoverflow.com/questions/24678144/conda-environments-and-bat-files call %CONDAPATH%\Scripts\activate.bat %ENVPATH% rem Run a python script in that environment python -c "import sys; print('Executed by: ', sys.executable)" rem Deactivate the environment call conda deactivate rem If conda is directly available from the command line then the following code works. rem call activate mikesdk rem python -c "import clr; print(clr.__version__)" rem conda deactivate rem One could also use the conda run command rem conda run -n mikesdk python -c "import sys; print('Executed by: ', sys.executable)"