environment-modules

loading-environment-modules-within-a-python-script

僤鯓⒐⒋嵵緔 提交于 2019-12-04 19:36:01
Loading environment modules within a python script The above solution behaves differently in the python interactive shell and within an executable python file & I need some help in understanding how to get it to work in the exe.py setting, where import statements appear not to be seeing the environment variable PYTHONPATH. In python shell the solution allows loading of an environment module which modifies PYTHONPATH; I can subsequently import a python module from that amended PYTHONPATH. This is great functionality & exactly what I want it to do in an executable python script. In a python

Loading environment modules within a python script

自作多情 提交于 2019-11-27 19:49:18
Is there a way for a python script to load and use environment modules ? os.system('module load xxx') doesn't work since it executes them in a subshell (at least, I think that's what's happening). I know this question's kind of old but it's still relevant enough that I was looking for the answer, so I'm posting what I found that works as well: At least in the 3.2.9+ sources, you can include the python "init" file to get a python function version of module: >>> exec(open('/usr/local/Modules/default/init/python.py').read()) >>> module('list') No Modulefiles Currently Loaded. >>> module('load',

Loading environment modules within a python script

强颜欢笑 提交于 2019-11-26 22:50:46
问题 Is there a way for a python script to load and use environment modules? os.system('module load xxx') doesn't work since it executes them in a subshell (at least, I think that's what's happening). 回答1: I know this question's kind of old but it's still relevant enough that I was looking for the answer, so I'm posting what I found that works as well: At least in the 3.2.9+ sources, you can include the python "init" file to get a python function version of module: >>> exec(open('/usr/local