Python is not recognizing text file that is in the same directory? -
my current project tree:
redditbot/ -- commands/ ----__init__.py ----comment_cache.txt ----readcomments.py --mainbot.py
what attempting read comment_cache.txt file via open('comment_cache.txt')
in readcomments.py file., reason getting filenotfounderror. when try print(os.path.isfile('comment_cache.txt'))
, returns false.
am making beginner mistake here? maybe keep missing?
edit: appreciate answers/comments, believe problem python interpreter itself. kept moving around file between redditbot/ directory , commands/ package until started working. reason whenever call print()
, pycharm tells me undefined...
i assuming mainbot.py
entry point run application,
problem i
based on project tree, file should available @ path
open('commands/comment_cache.txt')
problem ii
i kept moving around file between redditbot/ directory , commands/ package until started working.
you ended placing file in same folder mainbot.py
problem iii
also reason whenever call print(), pycharm tells me undefined...
there can many posibilities behind this, check if python interpreter configured correctly , python libraries available on pythonpath project
Comments
Post a Comment