ly4k / Certipy

Tool for Active Directory Certificate Services enumeration and abuse
MIT License
2.43k stars 338 forks source link

No module named 'pkg_resources' #215

Open exploide opened 5 months ago

exploide commented 5 months ago

Certipy does not only depend on setuptools during build time, it is also a runtime dependency because in https://github.com/ly4k/Certipy/blob/2780d5361121dd4ec79da3f64cfb1984c4f779c6/certipy/version.py#L1 the pkg_resources module is imported, which comes from the setuptools package.

If you install Certipy in a fresh environment (e.g. a new virtualenv, or via pipx, at least with Python 3.12) the module is not available and the following error occurs:

$ certipy
Traceback (most recent call last):
  File "/home/user/repos/Certipy/venv/bin/certipy", line 5, in <module>
    from certipy.entry import main
  File "/home/user/repos/Certipy/venv/lib/python3.12/site-packages/certipy/entry.py", line 6, in <module>
    from certipy import version
  File "/home/user/repos/Certipy/venv/lib/python3.12/site-packages/certipy/version.py", line 1, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

As a quick fix, setuptools should be added to the install_requires section of setup.py. However, according to the setuptools docs pkg_resources is deprecated anyway and should be substituted.

AV3T commented 4 months ago

For those that encounter the same issue, I found that injecting setuptools within the certipy-ad pipx environment helps with the error "ModuleNotFoundError: No module named 'pkg_resources":

pipx inject certipy-ad setuptools