Search code examples
pythonpython-idle

Code throws FileNotFoundException only on IDLE but not through CMD


Simple 2 line Python code is :

import pandas as pd 

pd.read_excel('sample.xlsx')

The above code runs fine when I go to the location of this folder & run from cmd but the same directory has the IDLE. When I use IDLE to run the same code it throws FileNotFoundError

Can anyone suggest where I am making mistake.


Solution

  • Very Basic mistake.

    Right clcik on the idle and goto properties.

    Goto --> Shortcut --> Start in : "--------"

    This is your default directory where the python is is trying to search the file. Change this directory to the folder where you want the python to search you file.

    I recommend to change this directory since you will work on many scripts which you would not want to be stored in default installation directory. Better create a seperate folder and give Kudos.