Semanage command fails with 'module 'pkg_resources' has no attribute 'get_distribution'

Solution Verified - Updated -

Issue

  • While executing semanage command, it fails with following error:
[root@xxx xxxxx]# semanage fcontext -a -t httpd_sys_content_t /etc/nginx/ header_hash.js
Traceback (most recent call last):
  File "/sbin/semanage", line 1000, in <module>
    do_parser()
  File "/sbin/semanage", line 970, in do_parser
    commandParser = createCommandParser()
  File "/sbin/semanage", line 900, in createCommandParser
    import seobject
  File "/usr/lib/python3.6/site-packages/seobject.py", line 33, in <module>
    import sepolicy
  File "/usr/lib/python3.6/site-packages/sepolicy/__init__.py", line 7, in <module>
    import setools
  File "/usr/lib64/python3.6/site-packages/setools/__init__.py", line 24, in <module>
    __version__ = pkg_resources.get_distribution("setools").version
AttributeError: module 'pkg_resources' has no attribute 'get_distribution'

Environment

  • Red Hat Enterprise Linux 8
  • Python3.6

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content