PEX warns about missing `setuptools` for `matplotlib` but it seems like it's not required
See original GitHub issuePEX warns about missing setuptools
for matplotlib
:
$ pip install pex
$ pex --version
2.1.92
$ pex matplotlib==3.5.2
/private/var/folders/t0/zb49xf010cq4mqzwwxw8f31h0000gp/T/tmpbwxjl1xt/.bootstrap/pex/environment.py:657: PEXWarning: The `pkg_resources` package was loaded from a pex vendored version when declaring namespace packages defined by:
1. matplotlib==3.5.2 namespace packages:
mpl_toolkits
These distributions should fix their `install_requires` to include `setuptools`
"should fix their `install_requires` to include `setuptools`".format(dists=dists)
Python 3.7.9 (default, Mar 12 2021, 20:11:13)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>>
However, a docker container without setuptools
is able to install matplotlib and import from the namespace package mpl_toolkits
:
$ cat Dockerfile
FROM ubuntu:18.04
# install python
RUN apt-get update && \
apt-get install --no-install-recommends -y \
python3.7 python3-pip python3.7-dev
RUN python3.7 -m pip install -U pip
RUN python3.7 -m pip install matplotlib
$ docker build -t check-container .
...
$ docker run --rm check-container pip list
Package Version
----------------- -------
cycler 0.11.0
fonttools 4.33.3
kiwisolver 1.4.3
matplotlib 3.5.2
numpy 1.21.6
packaging 21.3
Pillow 9.1.1
pip 22.1.2
pyparsing 3.0.9
python-dateutil 2.8.2
six 1.16.0
typing_extensions 4.2.0
$ docker run --rm check-container python3.7 -c 'from mpl_toolkits import mplot3d; print(dir(mplot3d))'
['Axes3D', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'art3d', 'axes3d', 'axis3d', 'proj3d']
I should acknoledge that without upgrading pip in the Dockerfile, it uses pip version 9, which is unable to install matplotlib because numpy and pillow fail to build and complain about missing setuptools
and gcc
. However with pip version 20.0.3+ there aren’t any issues.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
PEX warns about missing setuptools from install_requires in ...
This error is triggering the internal monitoring system (sentry) at our company. matplotlib is installed as catboost dependency.
Read more >No module named pkg_resources - python - Stack Overflow
This error message is caused by a missing/broken Python setuptools package. Per Matt M.'s comment and setuptools issue #581, the bootstrap script referred ......
Read more >pex 2.0.3 - PyPI
This builds a pex binary in dist/pex that can be copied onto your $PATH. The advantage to this approach is that it keeps...
Read more >Troubleshooting / common issues - Pants build system
Frequently asked questions (FAQs) and known issues you may encounter.
Read more >Dependencies — Matplotlib 3.6.2 documentation
When installing through a package manager like pip or conda , the mandatory dependencies are automatically installed. This list is mainly for reference....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think you should silence Pex in this case. As I pointed out,
matplotlib
wraps the namespace declaration in a try/except. Any import wrapped like that is, by definition, optional - the code author knows how to deal with the missing import / package it comes from. As such, they need not declare the dependency as aninstall_requires
since they just opportunistically use it if present.Thanks!