Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

3 of 3
replaced http://stackoverflow.com/ with https://stackoverflow.com/
user avatar
user avatar

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

jfs
  • 417.3k
  • 211
  • 1k
  • 1.7k

AltStyle によって変換されたページ (->オリジナル) /