Reputation: 1
import pandas
path = r"C:\Users\david\Documents\Excel\BitcoinPricesCopy.xlsx"
file = pandas.read_excel(path)
print(file)
Error:
File "C:\Users\david\Programming\MyPython\PycharmProjects\pythonProject\numbers.py", line 4, in file = pandas.read_excel(path) AttributeError: partially initialized module 'pandas' has no attribute 'read_excel' (most likely due to a circular import)
Upvotes: -1
Views: 410
Reputation: 3639
Looking at the error, it seems that the name of your python file is numbers.py
: this is the issue. Probably, it clashes with a module that Pandas loads (e.g., numbers; so, change the name of your script and the issue should be solved.
Moreover, mind that to read xlsx
files you need to use the right engine: you can choose the right one with the parameter engine
of the read_excel
function (e.g., openpyxl
).
Upvotes: 1
Reputation: 1221
The issue comes from your fiename numbers.py
as numbers
is an existing python module and probably imported in the pandas
one somewhere.
https://docs.python.org/3/library/numbers.html
This causes circular import as stated in the error, so you should rename your file.
Check this about circular imports: What happens when using mutual or circular (cyclic) imports in Python?
Upvotes: 1
Reputation:
Maybe your filename is Pandas.py that's why read_excel is unable to import its dependencies to read the xlsx file. Try renaming the file and then run
Upvotes: 0