Hey all, There’s an issue with pants not able to f...
# general
r
Hey all, There’s an issue with pants not able to find pkg_resources when torch is a dependency. Here are the other relevant dependencies in our pyproject.toml (used by poetry): before:
Copy code
torch=1.10.1
fsspec=0.8.7
pytorch_lightning=1.2.7
torchmetrics=0.3.2
hypothesis=6.30.1
matplotlib=3.5.0
While upgrading pytorch_lightning (to 1.5.0) and torchmetrics (0.6.0) we had dependency conflicts due to fsspec (2021.11.1) . When trying to import torch and running it through pants we got a “No module named pkg_resources found” error. We however were able to import torch on a virtualenv with the same exact modules installed without any error.
Copy code
_______ ERROR collecting file/path/test.py ________
ImportError while importing test module '/tmp/process-execution9BggO8/file/path/test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/shreyas/.pyenv/versions/3.7.12/lib/python3.7/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
file/path/test.py:4: in <module>
    import torch
/home/shreyas/.cache/pants/named_caches/pex_root/venvs/short/8b6cc6fb/lib/python3.7/site-packages/torch/__init__.py:29: in <module>
    from .torch_version import __version__ as __version__
/home/shreyas/.cache/pants/named_caches/pex_root/venvs/short/8b6cc6fb/lib/python3.7/site-packages/torch/torch_version.py:3: in <module>
    from pkg_resources import packaging  # type: ignore[attr-defined]
E   ModuleNotFoundError: No module named 'pkg_resources'
1