I have python script that works fine but only when run as stand-alone, while I need it as a script. It uses external .exe compiled C library in such manner:
# trigger the shell command
import subprocess
p = subprocess.Popen('qvoronoi TI data.txt TO results.txt p FN Fv QJ', shell=True)
p.wait()
# open the results file and parse results
results = open('results.txt','r')
It works all right when I run it as stand-alone.
But my program needs to be a script that works from inside another application (PTV Visum: http://www.ptvag.com/software/transportation-planning-traffic-engineering/software-system-solutions/visum/).
When I run it as a script from there it seems I cannot get permissions to write files (results.txt). Thats the error message:
IOError: [Errno 2] No such file or directory: 'results.txt'
How can I solve it.
PS. It tried os.chmod to change folder permissions but It didnt help
Try
print os.getcwd().Your current working directory is not the directory where
results.txtis being created.The
IOErroris on the line where you read the file, not write it, because you’re not specifying where to look forresults.txt.