I have the following section of code that works perfectly when I run it as a .py file. When I convert it to a .exe using py2exe it appears that the linecache.getline() function is not working properly. I am able to create and write the .txt file fine, so I believe the linecache function is the issue. Is there any workaround for this that does not use linecache to read a specified line from a textfile or is there a way to get linecache to work with Py2exe?
server = "en15"
pagenum = "0"
page = urllib.urlopen('http://www.westforts.com/%s/battles/page/%s' % (server, pagenum))
page_content = page.read()
with open('battle_id_getter%s.txt' % (pagenum) , 'w') as textfile:
textfile.write(page_content)
line = linecache.getline('battle_id_getter%s.txt' % (pagenum), 126)
Thanks in advance for any assistance you can provide.