ubuntu upgrade from18 to 20 ImportError: module ‘fabric.main’ has no attribute ‘program’

I guess I should start with I am not a sysadmin but I play one on TV.

I upgraded an ubuntu 18 machine to 20. We use fabric for deployment scripts. When I run fab on the CLI I now get an error message. See the stack trace below. I have tried reinstall and uninstalling fabric and have been trying to read up on the fabric 1 – 2 changes but nothing seems to be working for me. My fab file code is listed below the stack trace if that might be the problem. Any ideas on how to get this process running again would be greatly appreciated.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2453, in resolve
    return functools.reduce(getattr, self.attrs, module)
AttributeError: module 'fabric.main' has no attribute 'program'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/fab", line 11, in <module>
    load_entry_point('fabric==2.5.0', 'console_scripts', 'fab')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2455, in resolve
    raise ImportError(str(exc))
ImportError: module 'fabric.main' has no attribute 'program'

Fab file code:

#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'fabric==2.5.0','console_scripts','fab'
__requires__ = 'fabric==2.5.0'
import re
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(
        load_entry_point('fabric==2.5.0', 'console_scripts', 'fab')()
    )

I didn’t know the upgrade of fab would not work. I have tried reading about the fabric 1 and 2 documentation but nothing talks about if fab just won’t run at all.

I tried reinstalling fabric and installing fabric3.

Leave a Comment