Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
I'm trying to run my code on anaconda prompt and it gives me this error, any suggestions?
AttributeError: module 'nearest_neighbors' has no attribute 'knn_batch'


What I have tried:

I've tried pip install knn but no use
Posted
Updated 15-Oct-21 1:55am
Comments
Richard MacCutchan 15-Oct-21 7:35am    
You need to show the code that causes the error. No one here can possibly guess what you are trying to do.
Youssef Hany 2021 15-Oct-21 7:47am    
To write the code its complicated because several python files are imported so it'll be so long for anyone to read. My all problem is that KNN_batch is not available as an attribute of nearest_neighbors so I want to have it but don't know how
Richard MacCutchan 15-Oct-21 7:56am    
So look at the definition of nearest_neighbors to see what actual attributes it has.

1 solution

Quote:
To write the code its complicated because several python files are imported so it'll be so long for anyone to read. My all problem is that KNN_batch is not available as an attribute of nearest_neighbors so I want to have it but don't know how


And there's the problem: we can't see any of your code, so we have no idea what you are working with.
That's like you going for a drive, breaking down in the middle of nowhere, calling the garage, saying "it broke" and turning your phone off. How long do you think it will be before the garage arrives with the right part to fix your car, given that they don't know what car it is, what happened to it, or even where the heck it is?

We are in the same position: we can't fix problems when we have no information at all.

So it's going to be up to you. start by finding out what attributes nearest_neighbors has, and what module knn_batch is part of.

Then use the debugger pdb — The Python Debugger — Python 3.10.0 documentation[^].
Put a breakpoint on the first line in the function where the error occurs, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900