原因:之前使用pip进行安装openpyxl库,命令:pip install openpyxl
由于pip版本的问题使得安装的openpyxl为openpyxl 3.0.3,这在使用时会有版本更新后产生的问题。
解决方法:更新pip,卸载之前的openpyxl,重新安装。
1、更新pip的方法
可以使用
pip install -- upgrade pip
可能会报错:
TypeError: unsupported operand type(s) for -=: 'Retry' and 'int'
我使用的方法为
sudo apt-get remove python-pip python3-pip
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
这时候可能会报错找不到pip,可通过which pip定位,查看pip是否安装了。
确定存在,执行以下操作:
type pip
hash -r
至此,pip便弄好了。
2、删除之前的openpyxl库,重装。
pip uninstall openpyxl
pip install openpyxl
OK!