Use specific (python / Anaconda) environments in Shell Script

Hi,

I use Anaconda to work with python environments.
Unfortunately, I am not able to trigger a python script from BTT :pensive:

What I tried so far:

  • Played with the Launch Path (bin/bash, bin/zsh, /Users/lto/anaconda3/bin/python)
  • Trigger a shell script from BTT that then activates the conda environment

The error message is always (python not found).
I hope someone is here that has an idea :upside_down_face: Thanks !!!

CleanShot 2023-08-07 at 13.57.47

CleanShot 2023-08-07 at 14.01.28

BTT 4.157
Ventura 13.5
MacbookPro, M2

if you want to access the conda and python commands like this you would need to provide your PATH to BTT (otherwise it won't know where to look for the conda and python executable).

You can grab your path in your terminal app by entering
$PATH

In BTT you then use the "Environment Variables" section in your screenshot and enter PATH=the output from the command you just executed

For basic stuff adding PATH=/usr/bin is enough, because most binaries reside there. However I assume the conda & python environment is more complicated.

1 Like

I didn't get to manage it with Anaconda, it's probably just too complicated ... But thanks for your help :slight_smile:

My solution now, which works perfectly:
I just open the .sh file :smiley:

file.sh:

# Activate conda "base" environment
eval "$(conda shell.bash hook)"
conda activate base

# Run python script in current folder
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
python ${__dir}/schreibtisch_toggle.py

# Close Shell
# In your terminal settings, you can select "Close terminal after run" if you like
exit;

###
# Make Shell Script executable:
# sudo chmod +x file.sh
# Then make "Terminal" the standard app to open this file
###