🌐
GitHub
github.com › pandas-dev › pandas › issues › 48733
BUG: AttributeError: 'function' object has no attribute 'currentframe' · Issue #48733 · pandas-dev/pandas
September 23, 2022 - Traceback (most recent call last): File "C:\Users\artur\PycharmProjects\Ex_Files_Python_EssT\Exercise Files\Chap02\pandas_debug.py", line 15, in db.check_case_sensitive("TABLE2", "") File "C:\Users\artur\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pandas\io\sql.py", line 1664, in check_case_sensitive stacklevel=find_stack_level(inspect.currentframe()), AttributeError: 'function' object has no attribute 'currentframe' Same code was passing till version 1.4.4 ·
Author   huka81
🌐
Databricks
kb.databricks.com › python › function-object-no-attribute
AttributeError: 'function' object has no attribute
May 19, 2022 - Using protected keywords from the DataFrame API as column names results in a function object has no attribute error message. Written by noopur.nigam Last published at: May 19th, 2022 · You are selecting columns from a DataFrame and you get an error message. ERROR: AttributeError: 'function' object has no attribute '_get_object_id' in job
Discussions

final project - AttributeError: 'function' object has no attribute 'method' - CS50 Stack Exchange
Hey guys I've been working on my final project. I keep running into this error When I run flask, this error occurs File "/home/ubuntu/project/app.py", line 88, in login if request.method ... More on cs50.stackexchange.com
🌐 cs50.stackexchange.com
AttributeError: 'function' object has no attribute '__func__'
I tried to run the demo example for fine tuning the CodeT5+ Model in the README · however, I got the following error More on github.com
🌐 github.com
5
June 13, 2023
Don't know how to fix AttributeError: 'function' object has no attribute 'pk' when trying to create new users from registration form
Hi, I’m still very new to Python and Django. I am trying to create a working registration page and i get this error when submitting the form. I can’t find this error when looking on stack overflow or the forum and don’t know how to fix this issue. I copied the views and models code here. More on forum.djangoproject.com
🌐 forum.djangoproject.com
0
0
September 2, 2023
python - How to Prevent "AttributeError: 'function' object has no attribute ''" - Stack Overflow
I have been working on a program that is meant to encrypt messages inputted by the user. There are two encryption options, and the second one is meant to make each character in the message what it ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Python
python-list.python.narkive.com › E1Bg6h0e › i-think-i-found-a-bug-in-python-2-6-4-in-the-inspect-module
I think I found a bug in Python 2.6.4 (in the inspect module)
No, that wasn't the case. The argument of inspect.getargvalues() is a 'frame object' not 'function object'. ... inspect.getargvalues(inspect.currentframe()) You could argue that the error message is misleading (should be TypeError instead), do you want a bug report on that?
🌐
Itsourcecode
itsourcecode.com › home › attributeerror: ‘function’ object has no attribute
attributeerror: 'function' object has no attribute [SOLVED]
April 17, 2023 - The “AttributeError: ‘function’ object has no attribute” error occurs when you try to access an attribute or method of an object that doesn’t exist.
🌐
Cumulative Sum
cumsum.wordpress.com › 2021 › 03 › 05 › pandas-attributeerror-function-object-has-no-attribute-xxx
[pandas] AttributeError: 'function' object has no attribute xxx
March 6, 2021 - This error happens when you have a column name which conflicts with an existing method defined for data frame instance. For instance, given a data frame as below: df = pd.DataFrame({'count': ['yes', 'no', 'yes']}) df # count #0 yes #1 no #2 ...
🌐
GitHub
github.com › salesforce › CodeTF › issues › 29
AttributeError: 'function' object has no attribute '__func__' · Issue #29 · salesforce/CodeTF
June 13, 2023 - 1759 model, self.optimizer, self.lr_scheduler = self.accelerator.prepare( 1760 self.model, self.optimizer, self.lr_scheduler 1761 ) File [~/.conda/envs/codetf/lib/python3.8/site-packages/accelerate/accelerator.py:1182](https://vscode-remote+wsl-002bubuntu.vscode-resource.vscode-cdn.net/home/paul/projects/edu/master/mdl-ii/src/modeling/~/.conda/envs/codetf/lib/python3.8/site-packages/accelerate/accelerator.py:1182), in Accelerator.prepare(self, device_placement, *args) 1180 result = self._prepare_megatron_lm(*args) 1181 else: -> 1182 result = tuple( 1183 self._prepare_one(obj, first_pass=True,
Author   Paul-B98
🌐
JetBrains
youtrack.jetbrains.com › issue › PY-8940
'function' object has no attribute 'func_closure'" : PY-8940
November 1, 2021 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
Find elsewhere
🌐
Django Forum
forum.djangoproject.com › using django › forms & apis
Don't know how to fix AttributeError: 'function' object has no attribute 'pk' when trying to create new users from registration form - Forms & APIs - Django Forum
September 2, 2023 - Hi, I’m still very new to Python and Django. I am trying to create a working registration page and i get this error when submitting the form. I can’t find this error when looking on stack overflow or the forum and don’t know how to fix this issue. I copied the views and models code here.
Top answer
1 of 2
7

This similar question helped me discover the problem.

The Python documentation for the inspect module mentions both "frame records" and "frame objects", and explains the difference.

  • inspect.currentframe() returns a frame object, but
  • inspect.getouterframes() returns a list of frame records.

The mistake in the code above is not extracting the frame object from the frame record of the calling function, and passing inspect.getouterframes() the frame record instead of the frame object. (Note that inspect.getouterframes() doesn't check that its argument is a frame object.)

Here's the fixed definition of caller_args() (with the change to the assignment to caller_frame):

def caller_args():
    frame = inspect.currentframe()
    outer_frames = inspect.getouterframes(frame)
    caller_frame = outer_frames[1][0]
    return inspect.getargvalues(caller_frame)

Which runs as desired:

$ python getargvalues_test_fixed.py
ArgInfo(args=['arg1'], varargs=None, keywords=None, locals={'arg1': 'foo'})
2 of 2
-1

cause of error

AttributeError: 'tuple' object has no attribute 'f_code'

in your function

def caller_args()

is that caller_frame is an array of which you need item [1][0] as argument for

inspect.getargvalues(...)

this works :

currframe = inspect.currentframe()
callerframe = inspect.getouterframes(currframe, 2)
inspect.getargvalues(callerframe[1][0])

Also, the getargvalues function returns 4 values. First three are unimportant in this case, fourth contains JSON like format key/value list of callerframe arguments

 _,_,_,values = inspect.getargvalues(callerframe[1][0])
 for i in values:
     argsstring += str(i) + ' : ' + str(values[i])

My test looks like this :

import inspect

def log(text):
    currframe = inspect.currentframe()
    callerframe = inspect.getouterframes(currframe, 2)
    _,_,_,values = inspect.getargvalues(callerframe[1][0])
    argsstring = ''
    for i in values:
        argsstring += str(i) + ' : ' + str(values[i])
    print('name of file : ' + callerframe[1][1])
    print('name of function : ' + callerframe[1][3])
    print('line number : ' + str(callerframe[1][2]))
    print('caller function arguments : ' + argsstring)

def doTest(text):
    log(text) 

doTest('this is a test')
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
July 23, 2025 - We have included the "hasattr()" function inside the if-else to add logic to our code snippet. This will avoid the AttributeError: object has no attribute error.
🌐
Hugging Face
discuss.huggingface.co › beginners
Model = model.to(args.device) AttributeError: 'function' object has no attribute 'to' - Beginners - Hugging Face Forums
February 15, 2022 - I am getting this error when trying to do hyperparameter search Traceback (most recent call last): File "/gpfs7kw/linkhome/rech/genlig01/umg16uw/test/expe_5/traitements/gridsearch_flaubert.py", line 581, in trainer, outdir = prepare_fine_tuning(PRE_TRAINED_MODEL_NAME, train_dataset, val_dataset, ...
🌐
Fast.ai
forums.fast.ai › fastai
Resnet34 model: AttributeError: function object has no attribute 'children' - fastai - fast.ai Course Forums
August 11, 2022 - I was able to successfully create the model body you are looking for by instantiating the model class like this: create_body(resnet34(), cut=-2) · Additionally, I had to use from fastai.vision.all import * instead of just importing fastai (the top level library) · Sorry for the late reply, ...
Top answer
1 of 6
12

If this line

new_x = np.linspace(x.min(), x.max(), new_length)

is generating the error message

AttributeError: 'function' object has no attribute 'min'

then x is a function, and functions (in general) don't have min attributes, so you can't call some_function.min(). What is x? In your code, you've only defined it as

x=var

I'm not sure what var is. var isn't a default builtin in Python, but if it's a function, then either you've defined it yourself for some reason or you've picked it up from somewhere (say you're using Sage, or you did a star import like from sympy import * or something.)

[Update: since you say you're "using PyLab", probably var is numpy.var which has been imported into scope at startup in IPython. I think you really mean "using IPython in --pylab mode.]

You also define x1 and y1, but then your later code refers to x and y, so it sort of feels like this code is halfway between two functional states.

Now numpy arrays do have a .min() and .max() method, so this:

>>> x = np.array([0.1, 0.3, 0.4, 0.7])
>>> y = np.array([0.2, 0.5, 0.6, 0.9])
>>> new_length = 25
>>> new_x = np.linspace(x.min(), x.max(), new_length)
>>> new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x)

would work. Your test data won't because the interpolation needs at least 4 points, and you'd get

ValueError: x and y arrays must have at least 4 entries
2 of 6
3

Second question: how do I input more than one line of code at once? At the moment, if I try to copy the whole thing and then paste it into PyLab, it only inputs the top line of my code, so I have to paste the whole thing in one line at a time. How do I get round this?

Assuming you're in ipython called as ipython --pylab or something similar, then you can simply use the paste magic command. Call it as %paste or simply paste if you haven't defined paste as another variable:

In [8]: paste
import numpy as np
import scipy as sp
from scipy.interpolate import interp1d

x=var
x1 = ([0.1,0.3,0.4])
y1 = [0.2,0.5,0.6]

new_length = 25
new_x = np.linspace(x.min(), x.max(), new_length)
new_y = sp.interpolate.interp1d(x, y, kind='cubic')(new_x)

## -- End pasted text --
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-b4e41f59d719> in <module>()
      3 from scipy.interpolate import interp1d
      4 
----> 5 x=var
      6 x1 = ([0.1,0.3,0.4])
      7 y1 = [0.2,0.5,0.6]

NameError: name 'var' is not defined

In [9]: 
🌐
Reddit
reddit.com › r/learnpython › what is "attributeerror: 'function' object has no attribute 'find'"
r/learnpython on Reddit: what is "AttributeError: 'function' object has no attribute 'find'"
June 18, 2022 -
morseCodeM={".-":"A",
            "-...":"B",
            "-.-.":"C",
            "-..":"D",
            ".":"E",
            "..-.":"F",
            "--.":"G",
            "....":"H",
            "..":"I",
            ".---":"J",
            "-.-":"K",
            ".-..":"L",
            "--":"M",
            "-.":"N",
            "---":"O",
            ".--.":"P",
            "--.-":"Q",
            ".-.":"R",
            "...":"S",
            "-":"T",
            "..-":"U",
            "...-":"V",
            ".--":"W",
            "-..-":"x",
            "-.--":"Y",
            "--..":"Z",
            " / ":" "}
def morseToText(inp):
  out=""
  while(inp!=" "):
    for i in morseCodeM:
      if(inp.find(i)!=-1):    <-----------------------
        out=out+morseCodeM[i]
        inp2=list(inp)
        inp2[inp.find(i):inp.find(i)+(len(i)-1)]=""
        inp="".join(inp2)
        return out

I honestly don't know whats wrong it just gives the error :"AttributeError: 'function' object has no attribute 'find'" on the line with the arrow .

edit: the code is about converting morse code to text

🌐
GitHub
github.com › micropython › micropython › issues › 8432
AttributeError: 'function' object has no attribute '__name__' · Issue #8432 · micropython/micropython
March 20, 2022 - Some (maybe all) of the builtin functions do not have a __name__ attribute like regular functions: >>> def f(x): ... return x ... >>> f.__name__ 'f' >>> from math import sin >>> sin.__name__ Traceb...
Author   warnerjon12
🌐
Codecademy
codecademy.com › forum_questions › 534f3c4b52f8637aa1000033
Practice Makes Perfect : Function Object Has No Attribute Append Error | Codecademy
characters = [] reverse = [] def reverse(text): count = 0 for char in text: characters.append(char) el...
🌐
freeCodeCamp
forum.freecodecamp.org › python
function has no attribute - Python - The freeCodeCamp Forum
March 29, 2021 - I was watching the tutorial about developing a discord bot with python. At the 27th minute I started to get an error. I searched a lot but I couldn’t find a solution. Please help me to understand the situation here. My Code is: import discord import os import json import requests client = discord.Client() def get_quote(): response = requests.get ("https://zenquotes.io/api/random") json_data = json.loads(response.text) quote = json_data[0]["q"] + " -" + json_data[0]["a"] ...