Fixing Python TypeError: super() takes at least 1 argument (0 given)

TypeError: super() takes at least 1 argument (0 given) is an error which occurs when there is a compatibility problem between your python version and super() which results in an error.

In the blog post I attempt to explain why this error takes place and how you can solve it, I will also add other solutions that could solve the error if possible.

Exploring the TypeError: super() takes at least 1 argument (0 given)

This is an error which occurs when there is a compatibility problem between your python version and super() which results in an error.

The error you should have should be similar to the error bellow. Please make sure you do not confuse between errors.

                                                                       #
TypeError: super() takes at least 1 argument (0 given)
                                                                       #

Bellow we will describe how the error can be solved. With multiple possible solutions.

Solution 1 : Use python 3 instead , use update-alternatives

First, we should understand why the error is happening. This error occurs when there is a compatibility problem.

Specifically when you use super() with python 3 syntax while you are running python 2. Maybe your have python 3 but your default python version is python 2.

The solution is to use python 3 instead.

First, check which version of python you have using python –version. Continue if you have python 2.

Then, run the following command.

                                                                       #
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8
# use /usr/bin/python3.8 if you want python 3.8 , you can choose the latest version if you want
                                                                       #

Alternatively, you can start with the command bellow in order to switch to python 3 if you have it installed and avoid installing 3 versions of python. But if the command fails try the one above first

                                                                       #
sudo update-alternatives --config python
                                                                       #

The error should be gone by now. If this was not enough to fix your problem, check out the method bellow.

Solution 2 : use the future library in order to run python 3 code ( use pip install future )

An alternative solution for those who want to keep using python 3 syntax while running python 2, is to use the future library. You can install the future library using the command bellow

                                                                       #
pip install future
                                                                       #

Future is the missing compatibility layer between Python 2 and Python 3. The future library allows you to use a clean Python 3.x-compatible codebase to support both Python 2 and Python 3. You do not have to do anything else.

I hope the fix above fixed your problem, good luck with the scripts to come.

Summing-up : 

The end, we arrived at the end of this article, I hope my article helped you solve the error : Python TypeError super() takes at least 1 argument (0 given) , I am sure there are at least 10 other reasons why this error occurs, I can not find them all and explain them, this is my best attempt guys, Thank you for reading.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/