Hugh, 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 import qgis, osgeo, sklearn from sklearn import cluster, metrics from sklearn.cluster import DBSCAN from sklearn.metrics import silhouette_score print('Qapla') and the output prints 'Qapla' 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. Tyler
On Fri, May 27, 2022 at 11:06 AM Hugh Kelley <hghk...@gmail.com> wrote: > 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@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@lists.osgeo.org >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer >> > > > -- > Hugh Kelley > >
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer