nutritious-hair-72580
01/10/2024, 10:53 PMModuleNotFoundError
for flask_compress
while using Dash.
ImportError: To use the compress option, you need to install dash[compress]
I added an override for the 3rd party optional dependency
python_requirements(
name="reqs",
overrides={
"dash": {
"dependencies": [":reqs#Flask-Compress"],
}
}
)
but it still wasn't working.
Turns out I had both flask-compress=1.13
and Flask-Compress
in requirements.txt. After removing the latter, it works.
It works with just one or the other, or both with versions specified, but not in this first scenario. I'm not sure why.
I'm mainly posting for anyone else that searches for this specifically in future, but curious if Pants can do anything to better help here or if it's a bug.careful-address-89803
01/10/2024, 11:25 PMflask-compress==1.13
and Flask-Compress
to a requirements.txt, and import flask_compress
, I get the ambiguity warning below, and then Pants fails because it can't determine an owner.
[WARN] The target testprojects/src/python/sources/sources.py imports `flask_compress`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['testprojects/src/python:reqs#Flask-Compress', 'testprojects/src/python:reqs#flask-compress'].
If instead the import exists in a "weak" form (for example, inside of a try-except ImportError like would happen with a package's extra) then Pants will not mandate that a unique owner can be found (because you might not be using that extra).
Unfortunately, the warning can be cached and not re-emitted, which is be frustrating.
There's the source-analysis extra, which is a lot but really details the inner thoughts of Pants https://www.pantsbuild.org/docs/reference-python-dump-source-analysis . Although it looks like the weak-ignore took precedence over the ambiguous resolutionnutritious-hair-72580
01/10/2024, 11:50 PMpants --no-local-cache test
I don't get the import error. When I run with cache I do.
I don't see flask-compress in the source analysis dump in any case.careful-address-89803
01/11/2024, 12:51 AM