AttributeError: module 'openpyxl' has no attribute 'load_workbook'

asked 2019-06-14 07:14:40 -0500

dullarobin gravatar image

updated 2019-06-14 07:18:15 -0500

I'm a beginner in Python. After installing openpyxl 2.6.2 module using below command in pycharm terminal

pip install openpyxl.

=============CODE========================

from openpyxl import load_workbook

wb = load_workbook('transactions.xlsx')

====================END=======================

ERROR i'm facing

from openpyxl import load_workbook

File "C:\Users\robin.rana\PycharmProjects\HelloWorld\openpyxl.py", line 1, in <module>

from openpyxl import load_workbook

ImportError: cannot import name 'load_workbook' from 'openpyxl'

(C:\Users\robin.rana\PycharmProjects\HelloWorld\openpyxl.py)

edit retag flag offensive close merge delete

Comments

I cannot reproduce your error. But it looks strange why your openpyxl.py is in your personal folder instead of the ../site-pacakges/ dir. By the way, try not to use Pycharm but run the script directly using cmd. Also, for such questions, try stack overflow instead of here.

drsgao gravatar imagedrsgao ( 2019-06-14 09:30:18 -0500 )edit