Reputation: 1718
I'm pretty new with Python and finding some issues on a trivial code. I'm using Pycharm together with Anaconda.
This is my code:
posSentences = open('rt-polarity-pos.txt', 'r')
print (posSentences.read())
There is no issue in reading the file and printing it out when running it/terminal.
But when I try to run the same command in the console I get:
FileNotFoundError: [Errno 2] No such file or directory
I so checked the directories of the console, but they seem fine and are the same of the running file:
Thank you for your help!
Upvotes: 5
Views: 16721
Reputation: 5090
Python interpreter is run from Desktop\textan
but the file is in Desktop\textan\textan\
directory, so the path to the file in python code becomes textan\rt...txt
Upvotes: 1