Solution
Python script called by native LabVIEW functions, can not handle relative paths.
Instead of using relative path for configuration file, have full explicit path.
The following example doesn't return an error.
def file():
f=open("d:\\filename.txt",'w')
f.write('hi')
f.write('hi2')
f.close()
f=open("d:\\filename.txt",'r')
a=f.read()
f.close()
return a