I started now to learn Python, so my question is kinda stupid
I have this piece of code
#!/usr/local/bin/python3
# encoding: utf-8
fh = open("lines.txt")
for lines in readlines():
print(lines)
the text file lines.txt exits and it is at the same directory of my page, I using Komodo Edit, when I run the file, I get this error.
Traceback (most recent call last):
File "/Users/Jeff/Sites/PythonLearning/forloop.py", line 4, in <module>
fh = open("lines.txt")
IOError: [Errno 2] No such file or directory: 'lines.txt'
Funny thing, if i open this file in IDLE, it works nicely, as well if I open in Mac os X terminal!
Thanks a lot!!
You’re getting this error because by default when you run a script in Komodo Edit it does not run it from the directory the script is saved in (unlike when you run normally from the command terminal).
To fix this – when you select the ‘
Run Command‘ option in Komodo Edit – Click ‘More‘ to bring down a further options list and then in the ‘Start In‘ field enter%D. This tells Komodo to run the script from the directory it is in and should solve your problem.