0

I have tried answers posted here

But I still can't fix the same issue. Here is my python code:

import xlrd
import pandas as pd
from pandas import ExcelWriter
from pandas import ExcelFile

df = pd.read_excel('airquality.xlsx')

print("Column headings:")
print(df.columns)

:!python 'readexcel.py'

Traceback (most recent call last):
  File "readexcel.py", line 1, in <module>
    import xlrd
ImportError: No module named xlrd
shell returned 1

While I check the xlrd it shows it has been satisfied:

$python --version
Python 3.6.9
$ pip3 install xlrd
Requirement already satisfied: xlrd in /usr/local/lib/python3.6/dist-packages (1.2.0)

while in terminal, it seems no issue:

    python
    Python 3.6.9 (default, Nov  7 2019, 10:44:02)
    [GCC 8.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import xlrd
    >>>
David Z
  • 6,641
  • 11
  • 50
  • 101
  • 1
    Unrelated to your question, but I would advise against using `xlrd`. It's unmaintained, and is currently only recommended for handling the legacy .xls format. Also, are you not using virtual environments? – AMC Dec 23 '19 at 01:11

2 Answers2

0

Try:

pip3 install --upgrade xlrd
python3 readexcel.py
DumTux
  • 668
  • 1
  • 9
  • 24
0

Solved by in .vimrc (using !python3 instead of !python):

nnoremap <buffer> <F9> :exec '!python3' shellescape(@%, 1)<cr>
David Z
  • 6,641
  • 11
  • 50
  • 101