`iter_cols` gives a worksheet object has no attribute error?

After failing a bunch of times to get iter_cols to work with my code.

I tried using the example direct from documentation.

from openpyxl import load_workbook
from openpyxl import Workbook
wb = load_workbook("Trying web.xlsx")
ws = wb.active

for col in ws.iter_cols(min_row=1, max_col=3, max_row=2):
    for cell in col:


Traceback (most recent call last): File “”, line 1, in ws.iter_cols() AttributeError: ‘Worksheet’ object has no attribute ‘iter_cols’


You should check the version of openpyxl you are using.

import openpyxl

If that is an old version, you can get the newest version by upgrading