I want to activate my enviroment using script bash. This my scripten:
#! /bin/bash
export SPARK_HOME="/opt/mapr/spark/spark-3.1.2/"
source conda activate /home/mapr/miniconda3/envs/envPython
What is wrong in this script. when i run this command in terminal work correctly. Output expected:
bash scripten #i have to get my envPython conda
CodePudding user response:
Not exactly sure how to it cleanly but here is something that works for me
chmod x scriptensource scripten
This works fine for me (when activating venv).
Edit
scripten file
#!/usr/bin/env bash
export PYTHON_HOME="~/test/"
source ~/test/venv/bin/activate
screenshot
- top left:
source scriptenoutput - bottom left: content of
testdir - right: script file
CodePudding user response:
Try changing your shebang to run bash in login mode, i.e.,
#!/usr/bin/env bash -l
The Conda activate function is a shell function loaded through the shell resource file (e.g., .bashrc), so running a vanilla bash will not have it defined.

