[SOLVED] AttributeError: ‘function’ object has no attribute ‘read_excel’ python3

Issue

This Content is from Stack Overflow. Question asked by snorky

Even today I have a problem about the code, I am learning pyhton and I can not understand where I went wrong.

I am practicing by creating a fitness tracker that at each of my visits to the nutritionist and entering the data I return an excel file with the data I entered and then I would like to add a second page to it in order to view the graph that created the excel file

but the problem is my python program doesn’t save

def save():
    mese = entry2.get()
    altezza = entry3.get()
    peso = entry4.get()
    mmagra = entry5.get()
    mgrassa = entry6.get()
    utente = entry7.get()
    wb = Workbook()
    ws = wb.active
    ws['A1'] = "Mese"
    ws['B1'] = "Altezza"
    ws['C1'] = "Peso"
    ws['D1'] = "Massa Magra"
    ws['E1'] = "Massa Grassa"
    ws['F1'] = "Utente"
    ws['A2'] = mese
    ws['B2'] = altezza
    ws['C2'] = peso
    ws['D2'] = mmagra
    ws['E2'] = mgrassa
    ws['F2'] = utente
    wb.save(r'C:UserslricciDesktopSERVERwebGym TrackerGym Tracker v1.0track.xlsx')
    showinfo("Salvataggio")
    file1 = pd.read_excel("track.xlsx")
    file2 = pd.read_excel("trackn.xlsx")
    all = [file1, file2]
    append = pd.concat(all)
    append.to_excel("track.xlsx", index=False)

Solution

Two imports name are conflicting:

import pandas as pd

and

from turtle import pd, width

So when you call pandas functions by using pd, Python tries to call them on the pdfunction of turtle.

(You can notice the error is about a function, because pd is a function of the turtle package, not a module like pandas).

To fix this, you should import the turtle package import turtle and use turtle.pd() when you need the pd function from turtle, and directly pd when you need the pandas module.

Answered by PlainRavioli, This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5.CC BY-SA 3.0.CC BY-SA 4.0.

people found this article helpful. What about you?