I want to run a batch file in a Conda environment, not in the base env, but in another virtual environment (here pylayers).
I copied the activate.bat script from F:\Anaconda3\Scripts to F:\Anaconda3\envs\pylayers\Scripts.
And my batch script (installer_win.bat) is:
call F:\Anaconda3\envs\pylayers\Scripts\activate.bat
conda install numpy --yes
conda install mayavi --yes
conda install shapely --yes
conda install libgdal --yes
conda install gdal --yes
conda install h5py --yes
conda install seaborn --yes
conda install PIL --yes
conda install basemap --yes
conda install wxpython --yes
conda install netCDF4 --yes
pip install protobuf
pip install tqdm
pip install descartes
pip install bitstring
pip install geocoder
pip install triangle
pip install osmapi
pip install pyshp
pip install Image
pip install pathos
pip install SimPy==2.2
pip install simplekml
pip install smopy
python setup.py install
When I execute the installer_win.bat file, it shows the following behavior:
Output: #stops after executing very first line in the batch file.
(base) C:\Users\mkdth>activate pylayers
(pylayers) C:\Users\mkdth>cd /d F:\Pycharm\Projects\pylayers-master
(pylayers) F:\Pycharm\Projects\pylayers-master>installer_win.bat
(pylayers) F:\Pycharm\Projects\pylayers-master>call F:\Anaconda3\envs\pylayers\Scripts\activate.bat
The system cannot find the path specified.
(pylayers) F:\Pycharm\Projects\pylayers-master>conda install numpy --yes
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: F:\Anaconda3\envs\pylayers
added / updated specs:
- numpy
The following packages will be downloaded:
package | build
---------------------------|-----------------
openssl-1.1.1g | he774522_0 4.8 MB
------------------------------------------------------------
Total: 4.8 MB
The following NEW packages will be INSTALLED:
numpy-base pkgs/main/win-64::numpy-base-1.18.1-py36hc3f5095_1
The following packages will be SUPERSEDED by a higher-priority channel:
ca-certificates conda-forge::ca-certificates-2020.4.5~ --> pkgs/main::ca-certificates-2020.1.1-0
certifi conda-forge::certifi-2020.4.5.2-py36h~ --> pkgs/main::certifi-2020.4.5.1-py36_0
numpy conda-forge::numpy-1.18.5-py36h4d86e3~ --> pkgs/main::numpy-1.18.1-py36h93ca92e_0
openssl conda-forge --> pkgs/main
Downloading and Extracting Packages
openssl-1.1.1g | 4.8 MB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(pylayers) F:\Pycharm\Projects\pylayers-master>
I also tried to modify the batch file to activate pylayers environment from the base env and run the conda or pip commands one by one, but it installs to base environment only. See the bat script
Attempt 1
Installer_win.bat file:
call F:\Anaconda3\Scripts\activate.bat
activate pylayers
pause
conda install numpy --yes
conda install mayavi --yes
conda install shapely --yes
conda install libgdal --yes
conda install gdal --yes
conda install h5py --yes
conda install seaborn --yes
conda install PIL --yes
conda install basemap --yes
conda install wxpython --yes
conda install netCDF4 --yes
pip install protobuf
pip install tqdm
pip install descartes
pip install bitstring
pip install geocoder
pip install triangle
pip install osmapi
pip install pyshp
pip install Image
pip install pathos
pip install SimPy==2.2
pip install simplekml
pip install smopy
python setup.py install
Output: activates pylayers env and stops
(pylayers) F:\Pycharm\Projects\pylayers-master>installer_win.bat
(pylayers) F:\Pycharm\Projects\pylayers-master>call F:\Anaconda3\Scripts\activate.bat
(base) F:\Pycharm\Projects\pylayers-master>activate pylayers
(pylayers) F:\Pycharm\Projects\pylayers-master>
Attempt2:
Installer_win.bat file:
call F:\Anaconda3\Scripts\activate.bat
activate pylayers
conda install numpy --yes
conda install mayavi --yes
conda install shapely --yes
conda install libgdal --yes
conda install gdal --yes
conda install h5py --yes
conda install seaborn --yes
conda install PIL --yes
conda install basemap --yes
conda install wxpython --yes
conda install netCDF4 --yes
pip install protobuf
pip install tqdm
pip install descartes
pip install bitstring
pip install geocoder
pip install triangle
pip install osmapi
pip install pyshp
pip install Image
pip install pathos
pip install SimPy==2.2
pip install simplekml
pip install smopy
python setup.py install
Output: #activates base env and stops
(pylayers) F:\Pycharm\Projects\pylayers-master>installer_win.bat
(pylayers) F:\Pycharm\Projects\pylayers-master>call F:\Anaconda3\Scripts\activate.bat
(base) F:\Pycharm\Projects\pylayers-master>activate pylayers
Attempt 3
Installer_win.bat file:
call F:\Anaconda3\Scripts\activate.bat
conda install numpy --yes
conda install mayavi --yes
conda install shapely --yes
conda install libgdal --yes
conda install gdal --yes
conda install h5py --yes
conda install seaborn --yes
conda install PIL --yes
conda install basemap --yes
conda install wxpython --yes
conda install netCDF4 --yes
pip install protobuf
pip install tqdm
pip install descartes
pip install bitstring
pip install geocoder
pip install triangle
pip install osmapi
pip install pyshp
pip install Image
pip install pathos
pip install SimPy==2.2
pip install simplekml
pip install smopy
python setup.py install
Output: #starts installing in base env
(pylayers) F:\Pycharm\Projects\pylayers-master>installer_win.bat
(pylayers) F:\Pycharm\Projects\pylayers-master>call F:\Anaconda3\Scripts\activate.bat
(base) F:\Pycharm\Projects\pylayers-master>activate pylayers
(pylayers) F:\Pycharm\Projects\pylayers-master>installer_win.bat
(pylayers) F:\Pycharm\Projects\pylayers-master>call F:\Anaconda3\Scripts\activate.bat
(base) F:\Pycharm\Projects\pylayers-master>conda install numpy --yes
Collecting package metadata (current_repodata.json): failed
CondaError: KeyboardInterrupt
^CTerminate batch job (Y/N)?
^C
Can someone help me to run this batch file under a Conda virtual env, please?
Any suggestions would be very much appreciated.
conda env update -n pylayers -f env.yaml. Otherwise, to execute arbitrary scripts in an env there isconda run -n pylayers installer_win.bat. - mervcondais a batch file, should each one of those commands not be proceeded bycall? - Compo