Reputation: 93
I'm trying to run a python script through Task Manager from a specific virtual environment.
However, "activate.bat" only seems to exist in the root folder:
C:\Users\user\anaconda3\Scripts
but not in
C:\Users\user\anaconda3\envs\env_name\Scripts
I've tried using the following batch file as the Task Manager Program/Script but doesn't work (nothing happens). Any ideas on how to call a specific env here? Thanks!
@echo off
cd C:\Users\*user*\Documents\folderName\Scripts
call C:\Users\*user*\anaconda3\Scripts\activate.bat env_name
python test.py
Upvotes: 0
Views: 875
Reputation: 23
I have been using this method to create a windows batch (*.bat) file to run python scripts on a specific conda environment:
call "C:\ProgramData\Anaconda3\Scripts\activate.bat" env_name & python test.py
This allows me to quickly change the environment and run multiple lines of this for scripts that use different python environments configured for Python 3 and Python 2.
Upvotes: 0
Reputation: 77090
Generally, conda run
should be preferred for programmatic execution within an environment. The conda activate
command is intended for interactive use in a shell. That is, something like
@echo off
cd C:\Users\*user*\Documents\folderName\Scripts
conda run -n env_name python test.py
I'm not on Windows, but you may need conda.exe
or a full path to the Conda executable instead of simply conda
.
Upvotes: 1