Installing python xlrd module in Macs

Macs come with python pre-installed. Check which version of python you are running, navigate to terminal and run this command;

Step1:

python --version

Output:

Python 3.8.2

If you have python 3.x and higher you can proceed. Otherwise, upgrade your python package by going to https://www.python.org/, downloading the latest release and installing it using the installer.

Step2:

sudo easyinstall pip

If that command has been deprecated on your system, follow this link to finish the pip install; https://ahmadawais.com/install-pip-macos-os-x-python/

Step3: Install module xlrd with this command

pip install xlrd

If you get the error below it means that you are running two versions on python on your system and pip got installed on the older version.

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support

To solve the problem run this command

python3.8 -m pip install xlrd

Step4: Do a final upgrade to make sure you are running the latest version of pip

python3.8 -m pip install --upgrade pip

Output: Successfully installed pip-20.0.2

Recently I updated Python to latest version and needed to update the symlink in my terminal. Used command

ln -s -f /usr/local/bin/python3.10 /usr/local/bin/python

Ran the version check command to verify

Python 3.10.1

Enjoy!