polite-journalist-87208
12/06/2022, 10:11 PMImportError: Error while finding module specification for 'foo.d.bar' (ModuleNotFoundError: No module named 'foo')
polite-journalist-87208
12/06/2022, 10:12 PM>> ./pants run src/foo.d/bar.py
14:07:26.83 [INFO] Completed: Building foo.d.pex
Traceback (most recent call last):
File "/Users/taresh/.pyenv/versions/3.9.10/lib/python3.9/runpy.py", line 130, in _get_module_details
spec = importlib.util.find_spec(mod_name)
File "/Users/taresh/.pyenv/versions/3.9.10/lib/python3.9/importlib/util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'foo'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/taresh/.cache/pants/named_caches/pex_root/venvs/bf64290e98f45ccc125a4d62d33d0395b9387122/47e617753a41ccfadc734a273dae6b19d2268155/pex", line 236, in <module>
runpy.run_module(module_name, run_name="__main__", alter_sys=True)
File "/Users/taresh/.pyenv/versions/3.9.10/lib/python3.9/runpy.py", line 206, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/Users/taresh/.pyenv/versions/3.9.10/lib/python3.9/runpy.py", line 139, in _get_module_details
raise error(msg.format(mod_name, type(ex).__name__, ex)) from ex
ImportError: Error while finding module specification for 'foo.d.bar' (ModuleNotFoundError: No module named 'foo')
wondering if there is a workaround?enough-analyst-54434
12/06/2022, 10:22 PM$ mkdir spam.eggs
$ touch spam.eggs/oh_my.py
$ python -c 'from spam.eggs import oh_my'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'spam'
enough-analyst-54434
12/06/2022, 10:23 PMflat-zoo-31952
12/06/2022, 10:24 PMimportlib
to get at it since the syntax doesn't support it). You probably want to set up src/foo.d
as a source root https://www.pantsbuild.org/docs/source-rootspolite-journalist-87208
12/06/2022, 10:53 PM