Solving python AttributeError: module ‘module-name’ has no attribute ‘findall’

Python AttributeError: module ‘module-name’ has no attribute ‘findall’ is an error which occurs when confusion happens between a python module and one of your files.

I will explain why this error is taking place and how to fix it, while also trying to add other solutions that could help us solve the problem.

Exploring the python AttributeError: module ‘module-name’ has no attribute ‘findall’

There is an error which occurs when confusion happens between a python module and one of your files.

Please double check the error message bellow so you can avoid mixing between different errors.

                                                                       #
AttributeError: 'module' object has no attribute 'findall'
                                                                       #

In the sections bellow we will explain the source of the problem and propose many possible fixes.

The Method that solved the issue for me : Do not name your file : module-name.py , numpy.py , re.py or matplotlib.py for example

The error will take place when you try to import a python module while at the same time given a file the same name as the module you want to import.

For example, you want to import a package named module-name

                                                                       #
import module-name
                                                                       #

While having a file called module-name.py

Let us consider some examples, for instance you try to import a module named numpy

                                                                       #
import numpy
                                                                       #

While having a file called numpy.py

Or you try to import matplotlib while having a file called matplotlib.py

Maybe you are trying to import the re module

                                                                       #
import re
                                                                       #

While having a file called re.py

The concept is the same for all of these examples, there is a conflict between the file and the python module.

All you have to do is to rename your file and pick a different name.

I hope the fix above fixed your problem, good luck with your python projects, cheers.

Summing-up : 

That is it guys, this is the end of this article aka guide, I hope you found it useful in solving your problem, make sure to support our work on Kofi, you do not have to but hey you can donate to the team.

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/