bacpop / PopPUNK

PopPUNK 👨‍🎤 (POPulation Partitioning Using Nucleotide Kmers)
https://www.bacpop.org/poppunk
Apache License 2.0
87 stars 17 forks source link

Popunk installed with conda cannot import scikit-learn's KernelDensity #263

Closed sapoudel closed 1 year ago

sapoudel commented 1 year ago

This is only an issue with the conda installation. It is fixed on github.

Versions Poppunk version 1.2.2 Scikit-learn version 1.2.2

Installation conda install poppunk

Command used and output returned poppunk --version Output: ImportError

Describe the bug Popunk.plot.py tries to import KernelDensity from scikit-learn with from sklearn.neighbors.kde import KernelDensity and runs into ImportError because KernelDensity in newer sklearn now lives at sklearn.neighbors.KernelDensity

Fix A simple fix is to update the conda source to match the GitHub version where it has a try catch for import error. plot.py code from github that fixes the issue:

try:  # sklearn >= 0.22
    from sklearn.neighbors import KernelDensity
except ImportError:
    from sklearn.neighbors.kde import KernelDensity