How to fix ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support
Problem:
While trying to read a XLSX file using pandas
, you see an error message such as
File /usr/lib/python3.10/importlib/__init__.py:126, in import_module(name, package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
File :1050, in _gcd_import(name, package, level)
File :1027, in _find_and_load(name, import_)
File :1004, in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'xlrd'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
/home/uli/myproject/Analyze.ipynb Cell 3 in 2
18 # Determine absolute path
19 filepath = os.path.join(directory, filename)
...
--> 144 raise ImportError(msg)
145 else:
146 return None
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
Solution
You can install xlrd
using pip
:
sudo pip install xlrd