Bug 1729063 - [setroubleshoot] AttributeError: module 'pkg_resources' has no attribute 'get_distribution'
Summary: [setroubleshoot] AttributeError: module 'pkg_resources' has no attribute 'get...
Keywords:
Status: CLOSED INSUFFICIENT_DATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: python-pip
Version: 8.1
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: Python Maintainers
QA Contact: RHEL CS Apps Subsystem QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-07-11 10:32 UTC by guazhang@redhat.com
Modified: 2020-05-02 21:35 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-30 13:16:10 UTC
Type: Bug
Target Upstream Version:


Attachments (Terms of Use)

Description guazhang@redhat.com 2019-07-11 10:32:30 UTC
Description of problem:
abrt-cli check found the error what AttributeError: module 'pkg_resources' has no attribute 'get_distribution', please have a look

Version-Release number of selected component (if applicable):
setroubleshoot-server-3.3.19-2.el8.x86_64
RHEL-8.1.0-20190701.0 

How reproducible:
always


# /usr/sbin/setroubleshootd
Traceback (most recent call last):
  File "/usr/sbin/setroubleshootd", line 35, in <module>
    from setroubleshoot.util import log_debug
  File "/usr/lib/python3.6/site-packages/setroubleshoot/util.py", line 357, in <module>
    from sepolicy import get_all_file_types
  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'



Running: 'abrt-cli list'...
id 0afc6825a1065abd1b4076d71d9c540cdd4870df
reason:         module(): __init__.py:24:<module>:AttributeError: module 'pkg_resources' has no attribute 'get_distribution'
time:           Wed 10 Jul 2019 11:26:52 PM EDT
cmdline:        /usr/libexec/platform-python -Es /usr/sbin/setroubleshootd -f ''
package:        setroubleshoot-server-3.3.19-2.el8
uid:            993 (setroubleshoot)
count:          1
Directory:      /var/spool/abrt/Python3-2019-07-10-23:26:52-4106



# pip list 
Package              Version     
-------------------- ------------
asn1crypto           0.24.0      
cffi                 1.11.5      
configobj            5.0.6       
cryptography         2.3         
dbus-python          1.2.4       
decorator            4.2.1       
distro               1.4.0       
ethtool              0.14        
fmf                  0.6.1       
future               0.17.1      
gpg                  1.10.0      
idna                 2.5         
iniparse             0.4         
iotop                0.6         
ipaddress            1.0.22      
libsan               0.3.0       
netifaces            0.10.6      
pciutils             2.3.6       
perf                 0.1         
pexpect              4.7.0       
pip                  19.1.1      
ply                  3.9         
ptyprocess           0.6.0       
pycairo              1.16.3      
pycparser            2.14        
pygobject            3.28.3      
pyinotify            0.9.6       
pyOpenSSL            18.0.0      
pyparsing            2.1.10      
python-augeas        0.5.0       
python-dateutil      2.6.1       
python-dmidecode     3.12.2      
python-linux-procfs  0.6         
pyudev               0.21.0      
PyYAML               5.1.1       
rhnlib               2.8.6       
rpm                  4.14.2      
schedutils           0.6         
sepolicy             1.1         
setools              4.2.1       
setroubleshoot       1.1         
setuptools           41.0.1      
six                  1.11.0      
slip                 0.6.4       
slip.dbus            0.6.4       
sos                  3.7         
ssh2-python          0.18.0.post1
stqe                 0.1.3       
subscription-manager 1.25.11     
syspurpose           1.25.11     
systemd-python       234         
wheel                0.33.4    


platform-python-3.6.8-11.el8.x86_64

Comment 2 Miro Hrončok 2019-07-15 10:47:19 UTC
Have you ever used sudo pip?

Comment 3 Charalampos Stratakis 2019-07-30 13:16:10 UTC
Closing this. Please reopen if you have more information.

Comment 4 guazhang@redhat.com 2019-10-23 06:58:29 UTC
clean the needinfo

Comment 5 mjlad 2020-04-30 20:38:48 UTC
Hi
I have same problem I have website use wsgi and sqlite3 I get message:

[Thu Apr 30 19:20:50.821206 2020] [wsgi:error] [pid 11125:tid 139804262401792] [remote 37.39.148.69:39262] (sqlite3.OperationalError) attempt to write a readonly database

Then I did that:

chown -R apache:apache website_name/
semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/website_name(/.*)?"

Result:

Traceback (most recent call last):
  File "/usr/sbin/semanage", line 970, in <module>
    do_parser()
  File "/usr/sbin/semanage", line 947, in do_parser
    commandParser = createCommandParser()
  File "/usr/sbin/semanage", line 877, 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'

Comment 6 Miro Hrončok 2020-05-01 21:38:46 UTC
Hey. Have you ever used sudo pip? If so, the integrity of your system was unfortunately lost.

Verify the installation of your Python packages with:

$ rpm -V $(rpm -qa | grep python3)

Likely, files from python3-setuptools were deleted when you've used sudo pip in the past. You should be able to recover via:

$ sudo dnf reinstall python3-setuptools


Please never install packages via pip as root. Always use `pip install --user` or Python virtual environments.

See for example https://dev.to/elabftw/stop-using-sudo-pip-install-52mn

Comment 7 mjlad 2020-05-01 22:05:57 UTC
Yes I used pip as root

I did this but not fix it:
$ sudo dnf reinstall python3-setuptools

Comment 8 Miro Hrončok 2020-05-02 00:10:32 UTC
Please do share output of:

$ rpm -V $(rpm -qa | grep python3)

Comment 9 mjlad 2020-05-02 00:23:27 UTC
.M.......  g /var/cache/dnf/packages.db

Comment 11 Miro Hrončok 2020-05-02 09:04:06 UTC
Oh, I haven't realized this is RHEL. Could you please also do:

$ rpm -V $(rpm -qa | grep python)


And later:

$ sudo dnf reinstall platform-python-setuptools

Comment 12 mjlad 2020-05-02 14:57:26 UTC
missing     /usr/lib/python3.6/site-packages/__pycache__/easy_install.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/easy_install.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/__init__.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/__pycache__/py31compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/__init__.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/__pycache__/appdirs.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/__pycache__/pyparsing.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/__pycache__/six.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/appdirs.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__about__.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__init__.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/__about__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/_compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/_structures.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/markers.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/requirements.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/specifiers.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/utils.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/__pycache__/version.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/_compat.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/_structures.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/markers.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/requirements.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/specifiers.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/utils.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/packaging/version.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/pyparsing.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/_vendor/six.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/extern/__init__.py
missing     /usr/lib/python3.6/site-packages/pkg_resources/extern/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/pkg_resources/py31compat.py
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/DESCRIPTION.rst
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/INSTALLER
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/LICENSE.txt
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/METADATA
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/RECORD
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/WHEEL
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/dependency_links.txt
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/entry_points.txt
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/metadata.json
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/top_level.txt
missing     /usr/lib/python3.6/site-packages/setuptools-39.2.0.dist-info/zip-safe
missing     /usr/lib/python3.6/site-packages/setuptools/__init__.py
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/archive_util.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/build_meta.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/config.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/dep_util.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/depends.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/dist.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/extension.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/glibc.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/glob.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/launch.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/lib2to3_ex.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/monkey.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/msvc.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/namespaces.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/package_index.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/pep425tags.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/py27compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/py31compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/py33compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/py36compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/sandbox.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/site-patch.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/ssl_support.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/unicode_utils.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/version.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/wheel.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/__pycache__/windows_support.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/__init__.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/__pycache__/pyparsing.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/__pycache__/six.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__about__.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__init__.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/__about__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/_compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/_structures.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/markers.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/requirements.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/specifiers.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/utils.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/__pycache__/version.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/_compat.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/_structures.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/markers.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/requirements.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/specifiers.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/utils.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/packaging/version.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/pyparsing.py
missing     /usr/lib/python3.6/site-packages/setuptools/_vendor/six.py
missing     /usr/lib/python3.6/site-packages/setuptools/archive_util.py
missing     /usr/lib/python3.6/site-packages/setuptools/build_meta.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/__init__.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/alias.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/bdist_egg.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/bdist_rpm.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/bdist_wininst.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/build_clib.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/build_ext.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/build_py.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/develop.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/dist_info.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/easy_install.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/egg_info.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/install.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/install_egg_info.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/install_lib.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/install_scripts.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/py36compat.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/register.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/rotate.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/saveopts.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/sdist.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/setopt.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/test.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/upload.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/__pycache__/upload_docs.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/command/alias.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/bdist_egg.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/bdist_rpm.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/bdist_wininst.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/build_clib.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/build_ext.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/build_py.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/develop.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/dist_info.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/easy_install.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/egg_info.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/install.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/install_egg_info.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/install_lib.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/install_scripts.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/launcher manifest.xml
missing     /usr/lib/python3.6/site-packages/setuptools/command/py36compat.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/register.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/rotate.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/saveopts.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/sdist.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/setopt.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/test.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/upload.py
missing     /usr/lib/python3.6/site-packages/setuptools/command/upload_docs.py
missing     /usr/lib/python3.6/site-packages/setuptools/config.py
missing     /usr/lib/python3.6/site-packages/setuptools/dep_util.py
missing     /usr/lib/python3.6/site-packages/setuptools/depends.py
missing     /usr/lib/python3.6/site-packages/setuptools/dist.py
missing     /usr/lib/python3.6/site-packages/setuptools/extension.py
missing     /usr/lib/python3.6/site-packages/setuptools/extern/__init__.py
missing     /usr/lib/python3.6/site-packages/setuptools/extern/__pycache__/__init__.cpython-36.pyc
missing     /usr/lib/python3.6/site-packages/setuptools/glibc.py
missing     /usr/lib/python3.6/site-packages/setuptools/glob.py
missing     /usr/lib/python3.6/site-packages/setuptools/launch.py
top - 14:56:09 up 1 day, 17:25,  1 user,  load average: 0.00, 0.00, 0.00
missing     /usr/lib/python3.6/site-packages/setuptools/monkey.py
%Cpu(s):  0.2 us,  0.2 sy,  0.0 ni, 99.5 id,  0.0 wa,  0.0 hi,  0.2 si,
missing     /usr/lib/python3.6/site-packages/setuptools/namespaces.py
missing     /usr/lib/python3.6/site-packages/setuptools/package_index.py

missing     /usr/lib/python3.6/site-packages/setuptools/py27compat.py




Excellent, the problem was solved after reinstall platform-python-setuptools

Comment 13 mjlad 2020-05-02 14:58:38 UTC
Thank you

Comment 14 Miro Hrončok 2020-05-02 21:35:46 UTC
You are welcome.


Note You need to log in before you can comment on or make changes to this bug.