<div dir="ltr">Hugh,<div>I installed it all through the OSGeo4W installer, sklearn seems to install by default; when I run help("modules") in QGIS pyconsole I get sklearn returned in the list. Since I didn't install this myself I can only assume it installed with the OSGeo4W installer. That said, when i updated my installation sklearn seems to work. From QGIS pyconsole and Pycharm I can run<br>import qgis, osgeo, sklearn<br></div><div>from sklearn import cluster, metrics</div><div>from sklearn.cluster import DBSCAN</div><div>from sklearn.metrics import silhouette_score</div><div>print('Qapla')</div><div>and the output prints 'Qapla'</div><div>I am assuming it is working now, not sure how much of the import is necessary, I know when using Pycharm to use the geopandas from the OSGeo installer I have to import qgis and qgis processing before import geopandas as gp will work; or something to that effect.</div><div>Tyler</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 27, 2022 at 11:06 AM Hugh Kelley <<a href="mailto:hghklly@gmail.com">hghklly@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi Tyler, since I haven't seen anyone else respond I have a few questions/comments/suggestions.</div><div><br></div><div>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. <br></div><div><br></div><div>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. <br></div><div><br></div><div>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. <br></div><div><br></div><div>You might consider asking in a sklearn forum as this seems like more of a problem with sklearn than with qgis. <br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 26, 2022 at 9:49 AM Tyler Veinot via QGIS-Developer <<a href="mailto:qgis-developer@lists.osgeo.org" target="_blank">qgis-developer@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">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<div>"Traceback (most recent call last):</div>  File "C:\OSGeo4W\apps\Python39\lib\code.py", line 90, in runcode<br>    exec(code, self.locals)<br>  File "<input>", line 1, in <module><br>  File "<string>", line 6, in <module><br>  File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import<br>    mod = _builtin_import(name, globals, locals, fromlist, level)<br>  File "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\cluster\__init__.py", line 6, in <module><br>    from ._spectral import spectral_clustering, SpectralClustering<br>  File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import<br>    mod = _builtin_import(name, globals, locals, fromlist, level)<br>  File "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\cluster\_spectral.py", line 15, in <module><br>    from ..metrics.pairwise import pairwise_kernels<br>  File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import<br>    mod = _builtin_import(name, globals, locals, fromlist, level)<br>  File "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\metrics\__init__.py", line 37, in <module><br>    from . import cluster<br>  File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import<br>    mod = _builtin_import(name, globals, locals, fromlist, level)<br>  File "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\metrics\cluster\__init__.py", line 8, in <module><br>    from ._supervised import adjusted_mutual_info_score<br>  File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import<br>    mod = _builtin_import(name, globals, locals, fromlist, level)<br>  File "C:\OSGeo4W\apps\Python39\lib\site-packages\sklearn\metrics\cluster\_supervised.py", line 24, in <module><br>    from ._expected_mutual_info_fast import expected_mutual_information<br>  File "C:\OSGeo4W/apps/qgis-ltr/./python\qgis\utils.py", line 888, in _import<br>    mod = _builtin_import(name, globals, locals, fromlist, level)<br>ModuleNotFoundError: No module named 'sklearn.metrics.cluster._expected_mutual_info_fast'"<div>Has anyone had this issue and devised a work around?</div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr">Hugh Kelley       <br><div><br></div></div></div></div></div></div></div></div>
</blockquote></div>