pants: Failure to invoke pex: "No module named 'pex.bin'"

Users in a variety of environments have reported issues building either requirements.pex or pylint.pex, with failures like:

Traceback (most recent call last):
  File "/home/ziyadedher/.cache/pants/named_caches/pex_root/unzipped_pexes/42d4f75d046397e5f014ec8afd1a39b3ba8787c6/.bootstrap/pex/pex.py", line 446, in execute
    exit_code = self._wrap_coverage(self._wrap_profiling, self._execute)
  File "/home/ziyadedher/.cache/pants/named_caches/pex_root/unzipped_pexes/42d4f75d046397e5f014ec8afd1a39b3ba8787c6/.bootstrap/pex/pex.py", line 378, in _wrap_coverage
    return runner(*args)
  File "/home/ziyadedher/.cache/pants/named_caches/pex_root/unzipped_pexes/42d4f75d046397e5f014ec8afd1a39b3ba8787c6/.bootstrap/pex/pex.py", line 409, in _wrap_profiling
    return runner(*args)
  File "/home/ziyadedher/.cache/pants/named_caches/pex_root/unzipped_pexes/42d4f75d046397e5f014ec8afd1a39b3ba8787c6/.bootstrap/pex/pex.py", line 508, in _execute
    return self.execute_entry(self._pex_info.entry_point)
  File "/home/ziyadedher/.cache/pants/named_caches/pex_root/unzipped_pexes/42d4f75d046397e5f014ec8afd1a39b3ba8787c6/.bootstrap/pex/pex.py", line 610, in execute_entry
    return runner(entry_point)
  File "/home/ziyadedher/.cache/pants/named_caches/pex_root/unzipped_pexes/42d4f75d046397e5f014ec8afd1a39b3ba8787c6/.bootstrap/pex/pex.py", line 625, in execute_pkg_resources
    runner = entry.resolve()
  File "/home/ziyadedher/.cache/pants/named_caches/pex_root/unzipped_pexes/42d4f75d046397e5f014ec8afd1a39b3ba8787c6/.bootstrap/pex/vendor/_vendored/setuptools/pkg_resources/__init__.py", line 2481, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ModuleNotFoundError: No module named 'pex.bin'

Getting a reliable reproduction of this issue is blocking triage: if a user is experiencing this inside of a relatively reproducible environment (particularly Docker), capturing a top to bottom repro would be ideal. Failing that, the log output of a failing run with --pex-verbosity=9 and the content of ~/.cache/pants/named_caches/pex_root would be the next best thing.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 32 (29 by maintainers)

Commits related to this issue

Most upvoted comments

Alright. Tom was a huge help here testing out a fix. Although the root cause is still not nailed down, a plausible failure mode has been identified and confirmed to fix for Tom’s case, which reproed for him at a rate of ~75% prior to the fix. I’ve broken out https://github.com/pantsbuild/pex/issues/1272 to track landing the fix as well as the reasoning about the mechanism involved here - which is complex.