How to Install Xlrd in Python3 Library

How to Install Xlrd in Python3 Library

I am trying to install xlrd to read Excel files in python.

I have tried this: pip install -U pip setuptools. My macOS Mojave 10.4.3 has Python 2.7 which is where the default install goes to. But I have also installed Python3.7. How do I get pip install to my 3.7 directory?

3

3 Answers

I am on Mac machine(Catalina -version 10.15.5) and below pip3 command worked for me.

pip3 install xlrd

python version : 3.7.6

OS : Mac-Catalina(10.15.5)

1

Thanks to @Tapan Hegde, pip3 install xlrd worked from me, after installing the pip3, like this:

sudo apt update

apt install python3-pip

pip3 install xlrd

I reckon the easiest/cleanest solution would be to use a tool that isolates your python environment, such as virtualenv

Once installed, create a virtual env by specifying which version of python you want to use:

$> virtualenv -p python3 env

Note: puttin python3 directly works only for mac, with linux, you must specify the absolute path or your python binary.

And then 'activate' your environment:

$> source env/bin/activate

From here, any python or pip command you use will use python3.

$> pip install xlrd

Virtualenv has the advantage of not 'polluting' your local python installation, your can manage your pip modules installed more easily.

If you want more detail on how it works and the other alternatives, check this post

4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.