No more able to read excel file with pd.read_excel()

Hello everyone,

I’m using python since 1y now (mainly pandas and data analysis related packages). I use to work with Excel file for data import with pd.read_excel(). Issue is that since this morning I’m no more able to read any Excel file without gettint “SyntaxError: invalid syntax”.

If anyone knows what I can do, that wil be great :slight_smile:

###Quick context:
I have pandas 2.2.2 and python 3.9

only changes apply to my env are :
===> recently installed camelot lib
===> unistall and reinstall SQLAlchemy

####Here is what I’m trying to do
“df = pd.read_excel(‘budget_detail.xlsx’)>”

###Here is the complete error message

“”"
Traceback (most recent call last):

File "c:\Users\MyUserName\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3457, in run_code
  exec(code_obj, self.user_global_ns, self.user_ns)

File "<ipython-input-8-0a430088f42e>", line 8, in <module>
  df = pd.read_excel(p)

File "c:\Users\MyUserName\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 495, in read_excel
  io = ExcelFile(

File "c:\Users\MyUserName\Anaconda3\lib\site-packages\pandas\io\excel\_base.py", line 1537, in __init__
  if import_optional_dependency("xlrd", errors="ignore") is None:

File "c:\Users\MyUserName\Anaconda3\lib\site-packages\pandas\compat\_optional.py", line 135, in import_optional_dependency
  module = importlib.import_module(name)

File "c:\Users\MyUserName\Anaconda3\lib\importlib\__init__.py", line 127, in import_module
  return _bootstrap._gcd_import(name[level:], package, level)

File "<frozen importlib._bootstrap>", line 1030, in _gcd_import

File "<frozen importlib._bootstrap>", line 1007, in _find_and_load

File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked

File "<frozen importlib._bootstrap>", line 680, in _load_unlocked

File "<frozen importlib._bootstrap_external>", line 846, in exec_module

File "<frozen importlib._bootstrap_external>", line 983, in get_code

File "<frozen importlib._bootstrap_external>", line 913, in source_to_code

File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed

File "c:\Users\MyUserName\Anaconda3\lib\site-packages\xlrd\__init__.py", line 1187
  print "EXTERNSHEET(b7-):"
        ^

SyntaxError: invalid syntax

“”"

Finally found the solution.

xlrd version was downgraded to 0.7.1 version.
I have reinstalled pandas and openpyxl and upgraded xlrd.

Now it is working perfectly !!