Your indentation is goofed, and you've mixed tabs and spaces. Run the script with python -tt to verify.

Answer from Ignacio Vazquez-Abrams on Stack Overflow
🌐
GitHub
github.com › qdrant › qdrant › issues › 3517
AttributeError: 'ScoredPoint' object has no attribute 'collection_name' · Issue #3517 · qdrant/qdrant
February 3, 2024 - AttributeError: 'ScoredPoint' object has no attribute 'collection_name'#3517 · Copy link · Labels · bugSomething isn't workingSomething isn't working · abrahimzaman360 · opened · on Feb 3, 2024 · Issue body actions · langchain == 1.0.5 · langchain-community == 0.0.17 ·
Author   abrahimzaman360
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-attributeerror-object-has-no-attribute
How to fix AttributeError: object has no attribute - GeeksforGeeks
July 23, 2025 - The former indicates the type of error, and the latter suggests that the attribute we are trying to access does not exist for the object. Let us now proceed to discuss the common causes of this error.
🌐
Real Python
realpython.com › ref › builtin-exceptions › attributeerror
AttributeError | Python’s Built-in Exceptions – Real Python
Catching an AttributeError allows you to provide a graceful degradation or alternative solution when users try to access an attribute that’s missing. Accessing a method or attribute that doesn’t exist in a class or module ... Attempting to access attributes on a NoneType object due to uninitialized or improperly assigned variables
🌐
LabEx
labex.io › tutorials › python-how-to-resolve-attributeerror-in-python-415870
How to resolve AttributeError in Python | LabEx
In this case, the Person class does not have an age attribute, so trying to access it raises an AttributeError. Another common scenario is trying to access an attribute on an object that is None:
🌐
Reddit
reddit.com › r/learnpython › can't figure out: attributeerror - object has no attribute...
r/learnpython on Reddit: Can't figure out: AttributeError - object has no attribute...
July 2, 2023 -

Hi all. Hoping someone is able to help me with an error I cannot get rid of. It's confusing me because I am learning Python from the "Python Cash Course" book and the code is copied directly from the book, yet keeps throwing an AttributeError, as seen here:

Traceback (most recent call last):

File "/home/andy/python_work/Data Viz/die_visual.py", line 7, in <module> result = die.roll() File "/home/andy/python_work/Data Viz/die.py", line 11, in roll return randint(1, self.num_sides) AttributeError: 'Die' object has no attribute 'num_sides'

The code in the file I am trying to run is:

from die import Die

die = Die() results = [] for roll_num in range(100): result = die.roll() results.append(result) print(results)

And my Die() class is:

from random import randint

class Die(): """A class representing a single die""" def int(self, num_sides=6): self.num_sides = num_sides

def roll(self): """Return a random number between 1 and number of sides""" return randint(1, self.num_sides)

The code is from the book, I have tried re-writing it and have searched online to see if I could figure out why the error was occuring, but I'm just not seeing the answer. Any help would be appreciated.

🌐
Reddit
reddit.com › r/learnpython › object has no attribute error, but it actually does..
r/learnpython on Reddit: Object has no attribute error, but it actually does..
September 17, 2022 -

hello, i am working on a game using pygame and i am going for an OOP approach, the files are pretty big, i will post only a portion of the code; also i am using pycharm so i know for a fact my identation, typing are alright.. plus i have been coding in python for a while now but i just can't grasp onto this issue :(, so far in the game i am just in the main menu phase and whenever i try to run my code i get an error that my game object (which has a reference to another class including the main menu game loop) has no attribute ''screenWidth'' but it actually does have a variable for my screen.. i just use it in the main menu to set another midWidth variable half of that variable as value
here is the code:

main.py

from game import Game

myGame = Game()

while myGame.running:
    myGame.currentMenu.drawMainMenu()
    myGame.gameLoop()

game.py

import pygame
from menu import MainMenu


class Game:
    def __init__(self):
        pygame.init()

        self.running, self.playing = True, False
        self.upKey, self.downKey, self.selectKey, self.backKey = False, False, False, False

        self.currentMenu = MainMenu(self)

        self.screenWidth = 1280
        self.screenHeight = 720
        self.gameWindow = pygame.display.set_mode((self.screenWidth, self.screenHeight))
        pygame.display.set_caption("Game Prototype")

        self.backgroundImage = pygame.image.load('Assets/Images/bg_greek.jpg')
        self.backgroundImage = pygame.transform.scale(self.backgroundImage, (1920, 1080))

    def gameLoop(self):
        while self.playing:
            self.checkEvents()

            if self.selectKey:
                self.playing = False

            self.gameWindow.blit(self.backgroundImage, (-600, -300))

            pygame.display.flip()
            self.resetKeys()

menu.py

import pygame


class Menu:
    def __init__(self, game):
        self.gameClass = game
        self.midWidth = self.gameClass.screenWidth / 2
        self.midHeight = self.gameClass.screenHeight / 2
        self.showMenu = True
        self.selectionX, self.selectionY = 0, 0

    def drawSelection(self):
        selectSurface = pygame.Surface((260, 100), pygame.SRCALPHA)
        selectSurface.fill((50, 50, 50, 175))
        selectRect = selectSurface.get_rect()
        selectRect.center = (self.selectionX, self.selectionY)
        self.gameClass.gameWindow.blit(selectSurface, selectRect)


class MainMenu(Menu):
    def __init__(self, game):
        Menu.__init__(self, game)
        self.hoveredState = "Start"
        self.startX, self.startY = self.midWidth, self.midHeight
        self.optionsX, self.optionsY = self.midWidth, self.midHeight + 100
        self.creditsX, self.creditsY = self.midWidth, self.midHeight + 200
        self.quitX, self.quitY = self.midWidth, self.midHeight + 300
        self.selectionX, self.selectionY = self.startX, self.startY

    def drawMainMenu(self):
        self.showMenu = True
        while self.showMenu:
            self.gameClass.checkEvents()
            self.checkInput()

            self.gameClass.gameWindow.blit(self.gameClass.backgroundImage, (-600, -300))
            self.drawSelection()
            self.gameClass.drawText("Play", 72, self.startX, self.startY)
            self.gameClass.drawText("Options", 72, self.optionsX, self.optionsY)
            self.gameClass.drawText("Credits", 72, self.creditsX, self.creditsY)
            self.gameClass.drawText("Quit", 72, self.quitX, self.quitY)

            pygame.display.flip()
            self.gameClass.resetKeys()

it is not complete though

🌐
GitHub
github.com › langchain-ai › langchain › issues › 12629
AttributeError: 'PGVector' object has no attribute 'CollectionStore'. Did you mean: 'collection_name'? · Issue #12629 · langchain-ai/langchain
October 31, 2023 - embeddings = HuggingFaceEmbeddings(model_name='all-MiniLM-L6-v2') CONNECTION_STRING = "postgresql+psycopg2://hwc@localhost:5432/test3" COLLECTION_NAME = "state_of_the_union_test"
Author   anirbanpuky
🌐
GitHub
github.com › langchain-ai › langchain › issues › 16962
Qdrant: Performing a similarity search results in an "AttributeError" · Issue #16962 · langchain-ai/langchain
February 2, 2024 - from dotenv import load_dotenv from langchain.text_splitter import CharacterTextSplitter from langchain_community.document_loaders import TextLoader from langchain_community.vectorstores import Qdrant from langchain_openai import OpenAIEmbeddings load_dotenv() loader = TextLoader("../../modules/state_of_the_union.txt") documents = loader.load() text_splitter = CharacterTextSplitter(chunk_size=1000, chunk_overlap=0) docs = text_splitter.split_documents(documents) embeddings = OpenAIEmbeddings() qdrant = Qdrant.from_documents( docs, embeddings, location=":memory:", # Local mode with in-memory storage only collection_name="my_documents", ) query = "What did the president say about Ketanji Brown Jackson" found_docs = qdrant.similarity_search(query) print(found_docs[0].page_content)
Author   Sean Fitts(sfitts)
Find elsewhere
🌐
GitHub
github.com › explodinggradients › ragas › issues › 459
AttributeError("'list' object has no attribute 'get'") when calculating metrics score · Issue #459 · vibrantlabsai/ragas
January 13, 2024 - result = evaluate( llm=azure_model, dataset=dataset, # selecting only 3 metrics=[ context_precision, faithfulness, answer_relevancy, context_recall, context_relevancy ], ) Error trace [chain/error] [122:chain:row 120 > 125:chain:answer_relevancy] [6.01s] Chain run errored with error: "AttributeError("'list' object has no attribute 'get'")Traceback (most recent call last):\n\n\n File "C:\Users\allenpan\Anaconda\envs\rag_experiment\Lib\site-packages\ragas\metrics\base.py", line 71, in score\n score = self._score(row=row, callbacks=group_cm)\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n\n File "
Author   HuskyDanny
🌐
MongoDB
mongodb.com › working with data › python frameworks
(mongoDB and Python) AttributeError: 'InsertManyResult' object has no attribute 'inserted_count' - Python Frameworks - MongoDB Community Hub
October 19, 2022 - I follow the manual https://api.mongodb.com/python/3.4.0/api/pymongo/results.html and similar problem python - AttributeError: 'dict' object has no attribute 'is_active' (PyMongo And Flask) - Stack Overflow (not fit mine issue) after successfully .insert_many or .insert_one, the .inserted_count not working function main part I stock if one_or_many_bool == True: x = mycol.insert_many(insert_values_json) else: x = mycol.insert_one(insert_values_json) return x print(x) print(x.inse...
🌐
GitHub
github.com › pycaret › pycaret › issues › 876
AttributeError: '_PredictScorer' object has no attribute 'display_name' · Issue #876 · pycaret/pycaret
November 24, 2020 - AttributeError Traceback (most recent call last) <ipython-input-30-73f108423d5e> in <module> 1 rf = create_model('rf') 2 # tune catboost using custom scorer ----> 3 tuned_rf = tune_model(rf, custom_scorer = my_own_scorer) /opt/anaconda3/lib/python3.7/site-packages/pycaret/classification.py in tune_model(estimator, fold, round, n_iter, custom_grid, optimize, custom_scorer, search_library, search_algorithm, early_stopping, early_stopping_max_iters, choose_better, fit_kwargs, groups, return_tuner, verbose, tuner_verbose, **kwargs) 1099 verbose=verbose, 1100 tuner_verbose=tuner_verbose, -> 1101 **
Author   xg1990
🌐
GitHub
github.com › run-llama › llama_index › issues › 13614
[Bug]: weaviate client has no collection attributes · Issue #13614 · run-llama/llama_index
May 21, 2024 - 'LlamaIndex'" 169 ) 171 # create default schema if does not exist --> 172 if not class_schema_exists(self._client, index_name): 173 create_default_schema(self._client, index_name) 175 super().__init__( 176 url=url, 177 index_name=index_name, (...) 180 client_kwargs=client_kwargs or {}, 181 ) File ~/homebrew/Caskroom/miniconda/base/envs/test_env/lib/python3.11/site-packages/llama_index/vector_stores/weaviate/utils.py:76, in class_schema_exists(client, class_name) 74 """Check if class schema exists.""" 75 validate_client(client) ---> 76 return client.collections.exists(class_name) AttributeError: 'Client' object has no attribute 'collections'
Published   May 21, 2024
Author   arsyad2281
🌐
Stack Overflow
stackoverflow.com › questions › 75615356 › how-can-i-solve-the-attributeerror
python 3.x - How can I solve the AttributeError? - Stack Overflow
March 2, 2023 - I am running the code to evaluate some generated pictures and I keep getting issues. Here is the function : # Code adapted from # https://github.com/openai/improved-gan/blob/master/inception_score/...
Top answer
1 of 2
11

In short:

from nltk import precision

In long:

This is tricky. The issue occurred because of how NLTK was packaged. If we look at dir(nltk.metrics), there's nothing inside it, other than alignment_error_rate

>>> import nltk
>>> dir(nltk.metrics)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', 'alignment_error_rate']

BTW, in the bleeding edge version of NLTK, alignment_error_rate has been moved to nltk.translate.metrics, see https://github.com/nltk/nltk/blob/develop/nltk/translate/metrics.py#L10 . The nltk.translate package is a little unstable because it's still under-development.

Going back to the metrics package, from https://github.com/nltk/nltk/blob/develop/nltk/metrics/__init__.py, we see this:

from nltk.metrics.scores import          (accuracy, precision, recall, f_measure,
                                          log_likelihood, approxrand)
from nltk.metrics.confusionmatrix import ConfusionMatrix
from nltk.metrics.distance        import (edit_distance, binary_distance,
                                          jaccard_distance, masi_distance,
                                          interval_distance, custom_distance,
                                          presence, fractional_presence)
from nltk.metrics.paice           import Paice
from nltk.metrics.segmentation    import windowdiff, ghd, pk
from nltk.metrics.agreement       import AnnotationTask
from nltk.metrics.association     import (NgramAssocMeasures, BigramAssocMeasures,
                                          TrigramAssocMeasures, ContingencyMeasures)
from nltk.metrics.spearman        import (spearman_correlation, ranks_from_sequence,
                                      ranks_from_scores)

basically, this means that the functions from the metrics package has been manually coded and pushed up to nltk.metrics.__init__.py. So if the imports stop here, dir(metrics), would have listed all the metrics imported here.

But because on the higher level, at nltk.__init__.py https://github.com/nltk/nltk/blob/develop/nltk/__init__.py#L131, the packages was imported using:

from nltk.metrics import *

Now all metrics score has been imported to the top level meaning you can do:

>>> from nltk import precision
>>> from nltk import spearman_correlation
>>> from nltk import NgramAssocMeasures

But you can still access any intermediate level modules that are within nltk.metrics that are not imported in nltk.metrics.__init__.py. But you have to use the correct namespaces as how the functions are saved in their respective directory. Note that these will not show in dir(nltk.metrics) but are valid ways to import a function:

>>> from nltk.metrics import spearman
>>> from nltk.metrics import paice
>>> from nltk.metrics import scores
<function precision at 0x7fb584a34938>
>>> scores.precision
>>> spearman.spearman_correlation
<function spearman_correlation at 0x7fb5842b3230>
>>> from nltk.metrics.scores import precision
>>> precision
<function precision at 0x7fb584a34938>
2 of 2
0

Replace import of nltk.metrics by this :

from nltk.metrics import *

Now call precision or scores or recall directly.

🌐
Visual Components
forum.visualcomponents.com › python programming
Why am I getting AttributeError: 'NoneType' object has no attribute 'Name' - Python Programming - Visual Components - The Simulation Community
January 5, 2021 - Hello, I’m using sensor conveyor to detect what kind of parts are going trough the conveyor and then I want to append certain types of parts to a list. The entire script is pretty long as there is lot of other things happening in the script but in short this is how I try to get the name: ...