0

I am trying to execute a .bat file for creating an environment in conda and I am using the following script:

set HTTPS_PROXY=<some_value>  #will be setting some value
set HTTPS_PROXY=<some_vale>   #will be setting some value
conda create -n SATENV python=3.6 
activate SATENV 
set HTTPS_PROXY=<some_value>  #will be setting some value
set HTTPS_PROXY=<some_vale>   #will be setting some value
pip install -r requirements.txt  
python -m spacy download en 
python -m nltk.downloader stopwords 
conda deactivate 
python -m ipykernel install --user --name SATENV --display-name "SATENV"

In line number three conda create -n SATENV python=3.6 the batch script expects a user input (yes or no) to proceed for installing the new packages and as soon as the user responds, line three executes and the batch file stops executing other lines. Any leads on this will be really helpful.

Thanks in advance.

Parthasarathy Subburaj
  • 4,106
  • 2
  • 10
  • 24
  • Is `conda` another batch file? –  Nov 07 '19 at 13:35
  • You must `call conda...` and `call activate` We always `call` batch files. – Gerhard Nov 07 '19 at 13:37
  • @ a_horse_with_no_name no I don't have another batch file with name `conda` – Parthasarathy Subburaj Nov 07 '19 at 14:01
  • what is the name of this batch file? – Gerhard Nov 07 '19 at 14:02
  • @ Gerhard Barnard I tried using `call conda` but the still I run into the same issue... – Parthasarathy Subburaj Nov 07 '19 at 14:02
  • @ a_horse_with_no_name `satenv_win.bat` – Parthasarathy Subburaj Nov 07 '19 at 14:03
  • @ParthasarathySubburaj, it shouldn't be too difficult for you to have found out that `conda` is a batch file, because it has a `.bat` extension. I would suggest that you use `call conda.bat create -n SATENV python=3.6 -y` with the next line more like `call activate.bat SATENV`. Please note that you've not provided us with sufficient information for us to determine whether `activate.bat` and `conda.bat` reside in the current directory, if you cannot be sure they are, or cannot guarantee that their locations are somewhere within those listed under `%PATH%`, use the full paths to the batch files. – Compo Nov 07 '19 at 14:35
  • Why is twice defined `HTTPS_PROXY` with a string value? Shouldn't be first defined `HTTP_PROXY` and second `HTTPS_PROXY`? – Mofi Nov 07 '19 at 18:00
  • `activate` is with full name `activate.cmd`. It is a Windows batch file and not an executable. A batch file must be __called__ with command `call` as otherwise Windows command processor `cmd.exe` __continues__ processing of current batch file on other batch file without every returning back to current batch file. See also: [How to call a batch file that is one level up from the current directory?](https://stackoverflow.com/a/24725044/3074564) It explains all four methods which exist to run a batch file from within a batch file and what are the differences. – Mofi Nov 07 '19 at 18:03
  • It can be easily found out in a Windows command prompt window what is the full qualified file name of a program, i.e. what is the full path, file name and file extension of a script file or an executable. Just run `where activate` and `where python` and `where conda` and see what command [where](https://ss64.com/nt/where.html) outputs which is `%SystemRoot%\System32\where.exe`. The full qualified file name should be used wherever possible to avoid dependency on __local__ `PATH` and `PATHEXT` environment variables used by `cmd.exe` and `where.exe` to find files specified just with file name. – Mofi Nov 07 '19 at 18:10
  • 1
    @Compo your solution worked for me, thanks a lot. Do you want to post it an answer so that I can mark it as a verified answer which might help others who might visit this in the future? – Parthasarathy Subburaj Nov 08 '19 at 07:14

1 Answers1

1

Given that conda and activate are batch files:

Change:

conda create -n SATENV python=3.6 
activate SATENV 

To:

call conda.bat create -n SATENV python=3.6 -y
call activate.bat SATENV

Please note that I have also added the -y option to answer yes to any subsequent prompts, and prevent waiting to the end user to do so.

Compo
  • 36,585
  • 5
  • 27
  • 39