Solving Python AttributeError: module ‘attr’ has no attribute ‘s’

Python AttributeError: module ‘attr’ has no attribute ‘s’ is an error which occurs because of confusion or conflict between the attr and attrs libraries.

In today’s blog post I am going to present an annoying and confusing python error and explain why this error is taking place and how to fix it, with a set of possible fixes.

Exploring the Python AttributeError: module ‘attr’ has no attribute ‘s’

This is an error which occurs because of confusion or conflict between the attr and attrs libraries.

Do not mix between errors. Make sure the error message looks like the error message bellow

                                                                       #
AttributeError: module 'attr' has no attribute 's'
                                                                       #

I hope the method bellow will help you solve the problem and get rid of the error for good.

The Method that solved my problem : 

Correctly clean and install the attrs library (and the attr library)

The problem occurs when you do something like var=attr.ib() or attr.s which are the properties of the attrs library.

So, most developers will go ahead and install the attr library thinking that that is what they should install.

Which is going to cause the issue.

The solution is simple. Install the attrs library instead of installing the attr library.

There is also one other reason why the error might take place, the error can also happen if you have both the attrs library and the attr library installed, the solution remains approximately the same.

First step is to uninstall the attr library

                                                                       #
pip uninstall attr
                                                                       #

Second step is to uninstall attrs, only if you have already installed it of course.

                                                                       #
pip uninstall attrs
                                                                       #

Finally, install the attrs library using the pip package manager

                                                                       #
pip install attrs
                                                                       #

I hope the method above fixed your problem, good luck with your next python project.

Summing-up : 

We arrived at the end of this quest to solve this annoying error, I hope me sharing my experience with you helped, I hope the other solutions helped, If you like this website support us on Kofi and keep browsing, thank you.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/