简体   繁体   中英

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?

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)

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM