You could use a multiline string so that the environment is modified in the same shell process:
from subprocess import check_call
check_call("""
source /etc/profile.d/modules.sh
module purge
module load intel
./my_code
""", shell=True, executable="/bin/bash")
See also Calling the "source" command from subprocess.Popen Calling the "source" command from subprocess.Popen
You could use a multiline string so that the environment is modified in the same shell process:
from subprocess import check_call
check_call("""
source /etc/profile.d/modules.sh
module purge
module load intel
./my_code
""", shell=True, executable="/bin/bash")
You could use a multiline string so that the environment is modified in the same shell process:
from subprocess import check_call
check_call("""
source /etc/profile.d/modules.sh
module purge
module load intel
./my_code
""", shell=True, executable="/bin/bash")
You could use a multiline string so that the environment is modified in the same shell process:
from subprocess import check_call
check_call("""
source /etc/profile.d/modules.sh
module purge
module load intel
./my_code
""", shell=True, executable="/bin/bash")
You could use a multiline string so that the environment is modified in the same shell process:
from subprocess import check_call
check_call("""
source /etc/profile.d/modules.sh
module purge
module load intel
./my_code
""", shell=True, executable="/bin/bash")
You could use a multiline string so that the environment is modified in the same shell process:
from subprocess import check_call
check_call("""
source /etc/profile.d/modules.sh
module purge
module load intel
./my_code
""", shell=True, executable="/bin/bash")