I have written a simple python file where I am trying to read a text file and writing some log to a output file. Using pyinstaller I have created a .exe file. But when I am executing the that .exe file it is throwing the following error.
Traceback (most recent call last):
File "<string>", line 31, in <module>
File "<string>", line 15, in process_data
IOError: [Errno 2] No such file or directory: 'input1.txt'
mytest returned -1
Here is my code.
import re
import sys
import mytest2
def process_data(name, course):
tmp = sys.stdout
sys.stdout = open("out11.txt", 'w')
if re.search("^ank", name):
print "Yes I am here"
else:
print "No no wrong door"
fr = open("input1.txt", "r")
lines = fr.readlines()
fr.close()
print "Printing from input file.."
for line in lines:
print line.strip()
sys.stdout.close()
sys.stdout = tmp
if __name__ == "__main__":
arg1 = sys.argv[1]
arg2 = sys.argv[2]
process_data(arg1, arg2)
Can somebody tell me how to fix this one. I am doing this in Windows.
I also want to know whether this executable will work in all windows os like win 8, 8.1, 10 etc.
input1.txt
不在您具有.exe
的文件夹中,或者.exe
希望您将input1.txt
打包到其中onefile/singlefile
中的那个onefile onefile/singlefile
选项。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.