Short tip: Python TypeError: __init__() takes exactly 2 arguments (4 given)

Recently, I stumbled upon the following issue while installing a Python utility on an older CentOS system:

# python setup.py install
Traceback (most recent call last):
  File "setup.py", line 102, in 
    'katprep_snapshot=katprep.snapshot:cli',
  File "/usr/lib64/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/usr/lib/python2.7/site-packages/setuptools/command/develop.py", line 27, in run
    self.install_for_development()
  File "/usr/lib/python2.7/site-packages/setuptools/command/develop.py", line 129, in install_for_development
    self.process_distribution(None, self.dist, not self.no_deps)
  File "/usr/lib/python2.7/site-packages/setuptools/command/easy_install.py", line 701, in process_distribution
    distreq.project_name, distreq.specs, requirement.extras
TypeError: __init__() takes exactly 2 arguments (4 given)

The tool I wanted to install leverages the Python module setuptools for simplifying installation (easy_install). I ensured that the installation program syntax was correct – also, other tools were unable to install. Finally, I found out that the Python module was corrupted during numerous installations and uninstallations – re-installing it fixed the issue:

# yum reinstall python-setuptools

If re-installing the module is not working, it might also be an option to upgrade the module to a newer version using the Python package management:

pip install --upgrade setuptools

Leave a Reply