Skip to content

Instantly share code, notes, and snippets.

@ben-nour
Last active March 23, 2025 23:56
Show Gist options
  • Save ben-nour/fc29a6e2616808260bb23a26758e00ca to your computer and use it in GitHub Desktop.
Save ben-nour/fc29a6e2616808260bb23a26758e00ca to your computer and use it in GitHub Desktop.
Automating conda Python script on an admin-locked Windows computer.

1. Install Python via Anaconda

https://www.anaconda.com/download

2. Initialise conda into your shell

For Powershell:

conda init powershell

For Command Prompt:

conda init cmd.exe

https://stackoverflow.com/questions/64149680/how-can-i-activate-a-conda-environment-from-powershell

3. Write a batch script that activates conda

:: Activates the default conda environment:
call activate base 
:: Executes the script:
python "clean_up_old_sql_files.py" 

Note that calling conda activate base would not work as the rest of the .bat file would not execute as a new shell has been launched. At least this is the problem I had and using call is the solution.

4. Automate the .bat script via Windows Task Scheduler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment