0

Given below is the code that I am using to read values form a file

import linecache
line_number=line_number+1
linecache.getline("write.txt", line_number)

I am using py2exe to convert the file into an executable. The problem is after conversion to exe it cannot read the file.

The error message is: Could not convert string to a float

As suggested in the comment the full error trace is:

Traceback (most recent call last):
  File "logic.py", line 437, in <module>
  File "logic.py", line 224, in readdata
ValueError: could not convert string to float:

Where am I going wrong?

praxmon
  • 5,009
  • 22
  • 74
  • 121
  • Can you post all error trace message ? – fred.yu May 21 '14 at 04:41
  • @fred.yu Edited the question as you said. Please check and see. – praxmon May 21 '14 at 04:49
  • Open line 224 in `logic.py`, and see what makes the error. – fred.yu May 21 '14 at 04:55
  • @fred.yu I checked that already. Its the line where I try to access the value that I am reading from the file. – praxmon May 21 '14 at 04:57
  • I tried this code snippet, but it runs OK after I convert it to `exe`. So you try to comment some unrelated code and narrow down the problem. – fred.yu May 21 '14 at 05:00
  • @fred.yu Did you try to access the value that you are getting from the file? – praxmon May 21 '14 at 05:01
  • I try to get the content of the file `write.txt`, but failed. So I think it's a problem when use `linecache` with `py2exe`. Please look at [here](https://groups.google.com/forum/#!topic/wxpython-users/rOpIQEuX-NE). – fred.yu May 21 '14 at 05:22

0 Answers0