无法在Python 3.7中安装和使用模块'openpyxl'

时间:2019-07-24 20:43:03

标签: python pip openpyxl python-3.7

在我生命中,我无法在Python 3.7 / Windows /和Anaconda中安装和使用模块'openpyxl'。

当我尝试运行和/或调试程序时,始终会出现以下错误:

    import openpyxl
ModuleNotFoundError: No module named 'openpyxl'

尽管在我的终端机或Anaconda提示中:它表示已安装并满足要求。 即下面的

Requirement already satisfied: openpyxl in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (2.6.2)
Requirement already satisfied: jdcal in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.4)
Requirement already satisfied: et-xmlfile in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.0.1)

(base) C:\MYSELF\language\python\MLTSS-PDF-Split>pip install openpyxl
Requirement already satisfied: openpyxl in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (2.6.2)
Requirement already satisfied: jdcal in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.4)
Requirement already satisfied: et-xmlfile in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.0.1)

(base) C:\gitViews\language\python\MLTSS-PDF-Split>pip3 install openpyxl
Requirement already satisfied: openpyxl in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (2.6.2)
Requirement already satisfied: et-xmlfile in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.0.1)
Requirement already satisfied: jdcal in c:\users\MYSELF\appdata\local\continuum\anaconda3\lib\site-packages (from openpyxl) (1.4)

我尝试卸载并重新安装,我尝试使用pippip3

我尝试使用trusted host

我在Visual Studio Code中的导入行上没有错误;即

import openpyxl

为什么不能使用此模块?

1 个答案:

答案 0 :(得分:0)

正如评论中所讨论的,这似乎与您在Visual Studio Code中遇到的路径问题有关。

我的建议是使用他们的文档,以确保您指向的是本地版本的python,而不是未安装openpyxl的虚拟环境。

https://code.visualstudio.com/docs/python/environments