Closed
Description
Describe the bug
Since #17670, sklearn unconditionally imports pkg_resources. Such an import can be very slow (pypa/setuptools#926), so it should be avoided if possible.
Given that the point of #17670 was to improve support for prereleases, a possible fix could be for example to delay importing pkg_resources until needed, e.g.
def parse_version(v):
if {*v} <= {*"1234567890."}:
return LooseVersion(v)
else:
import pkg_resources
return pkg_resources.parse_version(v)
Steps/Code to Reproduce
Expected Results
Actual Results
N/A
Versions
System:
python: 3.9.1 (default, Dec 13 2020, 11:55:53) [GCC 10.2.0]
executable: /usr/bin/python
machine: Linux-5.9.14-arch1-1-x86_64-with-glibc2.32
Python dependencies:
pip: 20.3.3
setuptools: 51.1.1
sklearn: 0.23.2
numpy: 1.19.4
scipy: 1.5.4
Cython: 0.29.21
pandas: 1.1.5
matplotlib: 3.3.2.post2048+g263120690
joblib: 1.0.0
threadpoolctl: 2.1.0
Built with OpenMP: True