https://pantsbuild.org/ logo
#general
Title
# general
r

refined-addition-53644

04/22/2022, 2:33 PM
Hi, how would one go about fixing this issue
ModuleNotFoundError: No module named 'pkg_resources'
with using flake8-bandit plugin using pants. Please see ๐Ÿงต
โœ… 1
Copy code
16:32:00.27 [ERROR] Completed: Lint with Flake8 - flake8 failed (exit code 1).
Traceback (most recent call last):
  File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/7e6ce54894a5b483a1941fa56e1d20cbb228bf33/5be94140a3f8a3bde8451386d46e3d0f09111dc0/lib/python3.9/site-packages/flake8/plugins/manager.py", line 157, in load_plugin
    self._load()
  File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/7e6ce54894a5b483a1941fa56e1d20cbb228bf33/5be94140a3f8a3bde8451386d46e3d0f09111dc0/lib/python3.9/site-packages/flake8/plugins/manager.py", line 134, in _load
    self._plugin = self.entry_point.load()
  File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/metadata.py", line 86, in load
    module = import_module(match.group('module'))
  File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/7e6ce54894a5b483a1941fa56e1d20cbb228bf33/5be94140a3f8a3bde8451386d46e3d0f09111dc0/lib/python3.9/site-packages/flake8_bandit.py", line 13, in <module>
    from bandit.core.config import BanditConfig
  File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/7e6ce54894a5b483a1941fa56e1d20cbb228bf33/5be94140a3f8a3bde8451386d46e3d0f09111dc0/lib/python3.9/site-packages/bandit/__init__.py", line 19, in <module>
    __version__ = pbr.version.VersionInfo("bandit").version_string()
  File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/7e6ce54894a5b483a1941fa56e1d20cbb228bf33/5be94140a3f8a3bde8451386d46e3d0f09111dc0/lib/python3.9/site-packages/pbr/version.py", line 467, in version_string
    return self.semantic_version().brief_string()
  File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/7e6ce54894a5b483a1941fa56e1d20cbb228bf33/5be94140a3f8a3bde8451386d46e3d0f09111dc0/lib/python3.9/site-packages/pbr/version.py", line 462, in semantic_version
    self._semantic = self._get_version_from_pkg_resources()
  File "/Users/developer/.cache/pants/named_caches/pex_root/venvs/7e6ce54894a5b483a1941fa56e1d20cbb228bf33/5be94140a3f8a3bde8451386d46e3d0f09111dc0/lib/python3.9/site-packages/pbr/version.py", line 439, in _get_version_from_pkg_resources
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
I think it's something to do with pants using macos default python
n

narrow-vegetable-37489

04/22/2022, 2:51 PM
I believe you need to add
setuptools
as an extra requirement for flake8 since that plugin itself does not define it as a dependency.
๐Ÿ™Œ 2
๐Ÿ‘ 1
r

refined-addition-53644

04/22/2022, 2:55 PM
Thanks that worked!!