Unable to activate virtual environment from a shell script in macOS14 arm64

30 Views Asked by At

I attempted to activate the Python virtual environment from a shell script, but the environment did not activate successfully. The script executed without issues, and no errors were reported, but the virtual environment activation did not take place. I am using macOS14 arm64 machine.

Here is the code:

#!/bin/zsh

###
# step 1: create virtual environment
###
export ENV_PATH="/Users/tgol0006/uw_folder"
export INSTALL_NAME="uw3_boundary_integrals_env"
export INSTALL_PATH=$ENV_PATH/$INSTALL_NAME

HOME="/Users/tgol0006" # change it to your home dir

if [ ! -d "$INSTALL_PATH" ]
then
    echo "Environment not found, creating a new one"
    mkdir -p $INSTALL_PATH
    python3 --version
    python3 -m venv --system-site-packages $INSTALL_PATH
    source $INSTALL_PATH/bin/activate
else
    echo "Found Environment"
    source $INSTALL_PATH/bin/activate
fi

output:

 ~ ./uw3_install_mac_arm.sh
Found Environment

Any suggestions to fix this issue? Thanks

Created python virtual environment and activate it using source. However, environment did not activate.

0

There are 0 best solutions below