Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name get_column_letter

I am able to use openpyxl as an import in my code. But when I try to do the following:

from openpyxl.cell import get_column_letter 

I get the following error:

ImportError: cannot import name get_column_letter

I am using python 2.7. I have installed it using easy_install. Tried searching for this issue but couldn't find anything related to it.

like image 472
charsi Avatar asked Apr 19 '16 14:04

charsi


2 Answers

The function get_column_letter has been relocated in Openpyxl version 2.4 from openpyxl.cell to openpyxl.utils.

The current import is: from openpyxl.utils import get_column_letter

If you do not know which version the end-user has, you can use the following code:

try: 
    from openpyxl.cell import get_column_letter
except ImportError:
    from openpyxl.utils import get_column_letter
like image 184
Abbas Avatar answered Nov 15 '22 14:11

Abbas


from openpyxl.utils import get_column_letter

This is working for Python3 also.

like image 43
darla_sud Avatar answered Nov 15 '22 13:11

darla_sud