<#17531 Issue resolving generated Python module wi...
# github-notifications
q
#17531 Issue resolving generated Python module with source at root New issue created by dlsmith Describe the bug Python failed to resolve a generated module (in this case, from protobuf) when the project was structured with the Python source at the root of the package. My hypothesis is that this is due to the way Python resolves modules: it looks first in the execution directory, then to
PYTHONPATH
. Pants links the generated code from the sandbox via the
PYTHONPATH
, but if it replicates/preserves the semantics of Python, the interpreter may first look in a file tree with the parent module structure but without the generated files, leading to an import error. I've included a minimal example below that demonstrates the issue and works around it by nesting the source root under a
src/
prefix. Pants version 2.14.0 OS MacOS Additional info pants-codegen-repro.tar.gz pantsbuild/pants