Mock python errors

When trying to run mock to test RPM builds I python errors but not sure where the issues are coming from. I am installing mock from the RPM repos.

mock --help
Traceback (most recent call last):
  File "/usr/libexec/mock/mock", line 64, in <module>
    from mockbuild import config
  File "/usr/lib/python3.12/site-packages/mockbuild/config.py", line 27, in <module>
    from .util import set_use_nspawn, setup_operations_timeout
  File "/usr/lib/python3.12/site-packages/mockbuild/util.py", line 43, in <module>
    from pyroute2 import IPRoute
  File "/usr/lib/python3.12/site-packages/pyroute2/__init__.py", line 71, in <module>
    groups = metadata.entry_points()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/metadata/__init__.py", line 913, in entry_points
    return EntryPoints(eps).select(**params)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/metadata/__init__.py", line 910, in <genexpr>
    eps = itertools.chain.from_iterable(
                                       ^
  File "/usr/lib64/python3.12/importlib/metadata/_itertools.py", line 16, in unique_everseen
    k = key(element)
        ^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/metadata/__init__.py", line 835, in _normalized_name
    or super()._normalized_name
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/metadata/__init__.py", line 462, in _normalized_name
    return Prepared.normalize(self.name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/metadata/__init__.py", line 762, in normalize
    return re.sub(r"[-_.]+", "-", name).lower().replace('-', '_')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/re/__init__.py", line 186, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

Did you install any packages from PyPi with pip as root?
Do you have PYTHONPATH set?

Im sure I have installed packages as root but i don’t believe PYTHONPATH is set

echo $PYTHONPATH

Specifically did you use the pip3 or python3 -m pip commands as root?
Why I ask is that if you did that has a good chance of messing up system python.

Another thing you can try is to add a new user to your system and try mock from that user. If that works then there is something in your environment that breaks mock.

1 Like