Python - module 'pandas' has no attribute 'DataFrame'

By xngo on February 19, 2020

I wrote the following simple code to invoke pd.DataFrame().

import pandas as pd

And, it is throwing the following error message:

Traceback (most recent call last):
File "./", line 2, in
import pandas as pd
File "/media/master/github/python/", line 4, in
AttributeError: module 'pandas' has no attribute 'DataFrame'

This drove me crazy. The code that I wrote was perfectly correct.


It turns out. I put my code in and run it from that file. It messed up the import, resulting in this error.

Avoid calling your script or

About the author

Xuan Ngo is the founder of He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.