ModuleNotFoundError: No module named ‘openpyxl‘
由于python有多个版本:python2和python3,并且两个版本的模块还不能共用,因此有不同的pip版本:pip和pip3,分别用于安装python2和python3的模块;因此需要使用不同的pip版本安装python需要的模块;其实我已经安装过openpyxl了;但是为什么还是会报错呢?
文章共590字 · 阅读需要大约2分钟
一键AI生成摘要,助你高效阅读
问答
·
一、问题现象
执行python脚本的时候报错:
ModuleNotFoundError: No module named 'openpyxl'
其实我已经安装过openpyxl了;
# 安装命令
pip install openpyxl
# 查找已安装的模块
pip list |grep openpyxl
DEPRECATION: The default format will switch to columns in the future.
You can use --format=(legacy|columns) (or define a format=(legacy|columns)
in your pip.conf under the [list] section) to disable this warning.
openpyxl (2.6.4)
但是为什么还是会报错呢?
二、问题原因
由于python有多个版本:python2和python3,并且两个版本的模块还不能共用,因此有不同的pip版本:pip和pip3,分别用于安装python2和python3的模块;因此需要使用不同的pip版本安装python需要的模块;
python2的模块安装命令:
pip install openpyxl
python3的模块安装命令:
pip3 install openpyxl
如果pip3没有安装,则需要安装pip3:
sudo apt install python3-pip
最终问题就解决了:
pip list |grep openpyxl
DEPRECATION: The default format will switch to columns in the future.
You can use --format=(legacy|columns) (or define a format=(legacy|columns)
in your pip.conf under the [list] section) to disable this warning.
openpyxl (2.6.4)
pip3 list |grep openpyxl
DEPRECATION: The default format will switch to columns in the future.
You can use --format=(legacy|columns) (or define a format=(legacy|columns)
in your pip.conf under the [list] section) to disable this warning.
openpyxl (3.1.2)
更多推荐
已为社区贡献1条内容
所有评论(0)