Hi, I’m trying to use PyCall for some function defined in python. However, it keeps returning the ERROR “No module named sklearn” when I import python package sklearn. I’m pretty sure that sklearn works well with python on my computer. Can anyone help me with this? Thanks so much!
My code:
py"""
from sklearn.svm import SVR
import numpy as np
from sklearn.grid_search import GridSearchCV
from sklearn.metrics import mean_squared_error
from sklearn.kernel_ridge import KernelRidge
You have multiple versions of Python installed on your computer, and sklearn is not installed in the Python that PrCall is using. By default on Mac and Windows, PyCall installs its own Miniconda distro. If you want to have PyCall use a different Python installation, set the PYTHON environment variable and rebuild PyCall. See the PyCall documentation.
2 Likes
Thanks for your quick reply! I think this might be the reason. However, I tried to set the PYTHON env variable to a couple of paths, none of them works. How to find the correct path of python? I’m using Mac OS and I don’t have virtual environments.
which python
in the shell should tell you which Python you are running (assuming you do it by running python
in the shell).
@aliceee FYI You can use sklearn through:
-
scikitlearn.jl
-
MLJ.jl
- My code to train all sklearn models (& others) via MLJ: Custom XGBoost Loss function w/ Zygote. Julia Computing blog post - #13 by Albert_Zevelev
-
AutoMLPipeline.jl
And probably many others…
Thanks for your suggestion! I’ve tried ScikitLearn.jl package, but it does not support the function I wanted.