Python 101: Can't open file: No such file or directory

The Solution to Python 101: Can't open file: No such file or directory is


Prior to running python, type cd in the commmand line, and it will tell you the directory you are currently in. When python runs, it can only access files in this directory. hello.py needs to be in this directory, so you can move hello.py from its existing location to this folder as you would move any other file in Windows or you can change directories and run python in the directory hello.py is.

Edit: Python cannot access the files in the subdirectory unless a path to it provided. You can access files in any directory by providing the path. python C:\Python27\Projects\hello.p

~ Answered on 2015-12-05 20:08:37


Most Viewed Questions: