[QGIS-Developer] sklearn error

Hugh Kelley hghklly at gmail.com
Fri May 27 07:06:04 PDT 2022


Hi Tyler, since I haven't seen anyone else respond I have a few
questions/comments/suggestions.

What OS are you using? It looks like windows based on the file paths. since
sklearn has dependencies that require C bindings, you might have a much
easier time doing your work in either a linux environment (WSL might be
your easiest option), or using Anaconda.

How are you installing sklearn? I don't believe conda is compatible with
the way QGIS uses python, maybe others on the list will correct me about
that.

Possibly the most helpful thing I can suggest is not even bothering to try
to install anything for python on windows with pip, it works for some of
the basic libraries but most of the spatial libraries and probably the
machine learning type stuff end up requiring wheel files that are just very
difficult to get set up correctly.

You might consider asking in a sklearn forum as this seems like more of a
problem with sklearn than with qgis.



On Thu, May 26, 2022 at 9:49 AM Tyler Veinot via QGIS-Developer <
qgis-developer at lists.osgeo.org> wrote:

> I am trying to use sklearn in QGIS python console, it is showing up as
> installed and I can import modules from it but when I run script I get the
> error message
> "Traceback (most recent call last):
>   File "C:\OSGeo4W\apps\Python39\lib\code.py", line 90, in runcode
>     exec(code, self.locals)
>   File "<input>", line 1, in <module>
>   File "<string>", line 6, in <module>
>   File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in
> _import
>     mod = _builtin_import(name, globals, locals, fromlist, level)
>   File
> "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\cluster\__init__.py",
> line 6, in <module>
>     from ._spectral import spectral_clustering, SpectralClustering
>   File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in
> _import
>     mod = _builtin_import(name, globals, locals, fromlist, level)
>   File
> "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\cluster\_spectral.py",
> line 15, in <module>
>     from ..metrics.pairwise import pairwise_kernels
>   File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in
> _import
>     mod = _builtin_import(name, globals, locals, fromlist, level)
>   File
> "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\metrics\__init__.py",
> line 37, in <module>
>     from . import cluster
>   File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in
> _import
>     mod = _builtin_import(name, globals, locals, fromlist, level)
>   File
> "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\metrics\cluster\__init__.py",
> line 8, in <module>
>     from ._supervised import adjusted_mutual_info_score
>   File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in
> _import
>     mod = _builtin_import(name, globals, locals, fromlist, level)
>   File
> "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\metrics\cluster\_supervised.py",
> line 24, in <module>
>     from ._expected_mutual_info_fast import expected_mutual_information
>   File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in
> _import
>     mod = _builtin_import(name, globals, locals, fromlist, level)
> ModuleNotFoundError: No module named
> 'sklearn.metrics.cluster._expected_mutual_info_fast'"
> Has anyone had this issue and devised a work around?
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>


-- 
Hugh Kelley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220527/d705cfb6/attachment.htm>


More information about the QGIS-Developer mailing list