1

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?

python_beginner
  • 83
  • 1
  • 3
  • 9

4 Answers4

2

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)

Tapan Hegde
  • 1,222
  • 1
  • 8
  • 25
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
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40
Venkat
  • 21
  • 1
0

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

SivolcC
  • 3,258
  • 2
  • 14
  • 32
  • Thanks. I did that and installed xlrd 1.2.0. However when I do a pd.ExcelFile() in jupyter I get a error: Install xlrd >= 0.9.0 for Excel support – python_beginner Feb 11 '19 at 05:17
  • Check which version of `xlrd` has been installed by running `pip list | grep xlrd`. `pip` must have been using some cached version. Try to reinstall your pip modules with the `--no-cache-dir` option. I am not very familiar with Jupyter, so maybe the problem could come from somewhere else. – SivolcC Feb 11 '19 at 05:19
  • This answer is not valid anymore on Catalina which uses zsh, any help in this regard? – Nicholas Feb 11 '20 at 08:51
  • @Nicholas `pip3 install xlrd` worked for me. I am using Mac-catalina 10.15.5 version – Tapan Hegde Jul 16 '20 at 05:21
0

When pip install xlrd not work and in computer is still old version, then try do it with current version, for example pip install xlrd==2.0.1. The current versions are here