I have some experience sometimes a code works when use python script ( python script.py
) but doesn't work when I use jupyter notebook, with exactly conda enviroment and code.
The most recently case is: conda enviroment with python3.7.7, the code is
import subprocess
from subprocess import Popen
p1 = Popen(['sbatch', 'run2.txt'], stdout=subprocess.PIPE, shell=False, cwd=working_path)
p1.wait()
output = p1.communicate()[0]
print (output)
This code submits the job successfully for both ways (python script/jupyter notebook ). However, when submitting with jupyter notebook the slurm cluster can't run the job.
So I guess there are some foundemental differences between the two ways, or there are some settings I should know. Anyone can give me a help?
I found a clue that, from the output file of the submitted job, I can see when I use terminal or .py file to submit the job, the job create two threads but when I use .ipynb to submit the job, it doesn't create any thread.
Talked with cluster administrator, and they installed a system wide jupyter notebook and this version works. So the problem may be the previous version, installed by me in a conda enviroment, doesn't have some permission.