【问题标题】:Vim Python ImportError No module named xlrdVim Python ImportError 没有名为 xlrd 的模块
【发布时间】:2020-04-14 08:00:12
【问题描述】:

我已尝试发布here 的答案

但我仍然无法解决同样的问题。 这是我的python代码:

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

当我检查 xlrd 时,它表明它已被满足:

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

在终端中,似乎没有问题:

    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
    >>>

【问题讨论】:

  • 与您的问题无关,但我建议您不要使用xlrd。它未维护,目前仅推荐用于处理旧版 .xls 格式。另外,你没有使用虚拟环境吗?

标签: python vim


【解决方案1】:

在 .vimrc 中解决(使用 !python3 而不是 !python):

nnoremap <buffer> <F9> :exec '!python3' shellescape(@%, 1)<cr>

【讨论】:

    【解决方案2】:

    试试:

    pip3 install --upgrade xlrd
    python3 readexcel.py
    

    【讨论】:

      猜你喜欢
      • 2017-12-27
      • 1970-01-01
      • 2013-01-06
      • 2015-12-09
      • 2012-01-26
      • 2020-12-15
      • 2015-11-17
      • 2016-07-24
      • 2017-07-15
      相关资源
      最近更新 更多