ModuleNotFoundError: No module named ‘openpyxl‘

ModuleNotFoundError: No module named 'openpyxl'

一、问题现象

执行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)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值