Open Watxtract-Christina opened 5 years ago
Helllo, Could you try this in the Qgis python console :
from pip._internal import main as pip
pip(['install', '--user', 'scikit-learn'])
Traceback (most recent call last):
File "/usr/lib/python3.6/code.py", line 91, in runcode
exec(code, self.locals)
File "", line 1, in
Hello,
How did you install Qgis in ubuntu ? Because normally dependences installed in Ubuntu (pip/sklearn in python...) are shared inside Qgis environment. I'm not an expert of this, but try to install pip in the Qgis environment (I see differences between /usr/lib/python3/
used for Qgis in your installation and ./.local/lib/python3.6/
your default python path).
@Watxtract-Christina , do you find a way to install scikit-learn since ?
I installed scikit-learn for QGIS 3.4 using pip3 instead of pip, because I have both python 2 and 3, and since QGIS 3+ versions are based on python 3, I guess this should work for you.
Also, thinking of lennepkade's comment, I have these paths:
scikit-learn in /usr/local/lib/python3.6/dist-packages scipy>=0.17.0 in /usr/lib/python3/dist-packages (from scikit-learn) numpy>=1.11.0 in /usr/lib/python3/dist-packages (from scikit-learn) joblib>=0.11 in /usr/local/lib/python3.6/dist-packages (from scikit-learn)
Hello,
I found that the problem isn't due to sklearn install, but it is much more deep...or should I say recursive. "RecursionError: maximum recursion depth exceeded while calling a Python object".
I was able to catch it by adding a 'raise' in the dzetsaka.py file. It seems impossible to import sklearn from a pyqgis scope ; here is the traceback. traceback_sklearn.txt QGIS-3.10 ; python-3.7.3 ; scikit-learn-0.20.2
It looks pretty similar to an issue I opened on the QGIS repo (see https://github.com/qgis/QGIS/issues/33612 ) : there is no way to import pandas after qgis.core. Something related to special methods and attributes (__dict__)... it may be hard to fix for now.
I was able to fix it with a newer version of sklearn. In Debian10 or Ubuntu18, the default version installed with apt is 0.20.x . I had to remove the system version and then install a 0.22 with pip, now everything seems to work ! May be you should add a requirements.txt or something like that to specify a minimum version.
Hello @vidlb ,
Thanks for the feedback and for the solution !
@Watxtract-Christina and @ppopoca , if you still have scikit-learn issues (sklearn not found), can you type this in the OSGEO :
python3 -m pip install scikit-learn -U --user
The -U forces the update of scikit-learn, as @vidlb found that maybe the problem came from version 0.20.*.
In any case, can you tell me if you found a successful solution ? Or if you still failed to use sklearn ?
When I tried to run SVM in qgis using the plugin, I got the library missing message "Scikit-learn library is missing on your computer." Although I have scikit-learn in my system: Requirement already satisfied: scikit-learn in ./.local/lib/python3.6/site-packages (0.20.3) Requirement already satisfied: scipy>=0.13.3 in ./.local/lib/python3.6/site-packages (from scikit-learn) (1.2.1) Requirement already satisfied: numpy>=1.8.2 in ./.local/lib/python3.6/site-packages (from scikit-learn) (1.16.2) How to let QGIS recognize the library? System: ubuntu 18.04. Try type:import sklearn in python console in qgis, it seems the scikit-learn is not installed in qgis.