Python Forum

Full Version: Python Application Not Finding Excel File
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey Guys,

I am a newbie in Python! I am trying to import my excel data in python! But I always keep getting this error! I don't know what to do! I am setting the right directory in this line my pd.read_excel... What else could this be?

import pandas as pd
pd.read_excel('This PC/Desktop/IST 467 Data Mining/Module3/Students.xlsx', sheet_name='Sheet1')
But this is the error I keep getting below:

FileNotFoundError Traceback (most recent call last) <ipython-input-15-42b58c01f825> in <module> ----> 1 pd.read_excel('This PC/Desktop/IST 467 Data Mining/Module3/Students.xlsx', sheet_name='Sheet1') ~\anaconda3\lib\site-packages\pandas\util\ in wrapper(*args, **kwargs) 294 ) 295 warnings.warn(msg, FutureWarning, stacklevel=stacklevel) --> 296 return func(*args, **kwargs) 297 298 return wrapper ~\anaconda3\lib\site-packages\pandas\io\excel\ in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols) 302 303 if not isinstance(io, ExcelFile): --> 304 io = ExcelFile(io, engine=engine) 305 elif engine and engine != io.engine: 306 raise ValueError( ~\anaconda3\lib\site-packages\pandas\io\excel\ in __init__(self, path_or_buffer, engine) 865 self._io = stringify_path(path_or_buffer) 866 --> 867 self._reader = self._engines[engine](self._io) 868 869 def __fspath__(self): ~\anaconda3\lib\site-packages\pandas\io\excel\ in __init__(self, filepath_or_buffer) 20 err_msg = "Install xlrd >= 1.0.0 for Excel support" 21 import_optional_dependency("xlrd", extra=err_msg) ---> 22 super().__init__(filepath_or_buffer) 23 24 @property ~\anaconda3\lib\site-packages\pandas\io\excel\ in __init__(self, filepath_or_buffer) 351 = self.load_workbook(filepath_or_buffer) 352 elif isinstance(filepath_or_buffer, str): --> 353 = self.load_workbook(filepath_or_buffer) 354 elif isinstance(filepath_or_buffer, bytes): 355 = self.load_workbook(BytesIO(filepath_or_buffer)) ~\anaconda3\lib\site-packages\pandas\io\excel\ in load_workbook(self, filepath_or_buffer) 35 return open_workbook(file_contents=data) 36 else: ---> 37 return open_workbook(filepath_or_buffer) 38 39 @property ~\anaconda3\lib\site-packages\xlrd\ in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows) 109 else: 110 filename = os.path.expanduser(filename) --> 111 with open(filename, "rb") as f: 112 peek = 113 if peek == b"PK\x03\x04": # a ZIP file FileNotFoundError: [Errno 2] No such file or directory: 'This PC/Desktop/IST 467 Data Mining/Module3/Students.xlsx'
Is this 'This PC/Desktop/IST 467 Data Mining/Module3/Students.xlsx' Really the path?
looks problematic at best
try something like this instead. yourUsername needs to be whatever username you log into your system with

'c:\users\yourUsername\desktop\IST 467 Data Mining\Module3\Students.xlsx'