Seems like your import from program2 import results
searching for a file named info.fits
which is located most probably in '/software/xray/Python_scripts'
.
Basically, sys.path.insert
temporarily adds path to PATH
, in order to make OS executing/importing script from that place. It doesn't mean that it becomes a file search path as well.
You need to do somethig like:
import os
cwd = os.getcwd()
os.chdir('/software/xray/Python_scripts')
from program2 import results
os.chdir(cwd)
It is certainly a crunch, I would suggest you to create a package out of your program2 module. https://realpython.com/python-modules-packages/
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…