The Python package sklearn could not be found by pyimport. Usually this means
that you did not install sklearn in the Python version being used by PyCall.
PyCall is currently configured to use the Python version at:
/usr/bin/python3
and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the sklearn module.
One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.
Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia. As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the sklearn module, you can use pyimport_conda("sklearn", PKG),
where PKG is the Anaconda package the contains the module sklearn,
or alternatively you can use the Conda package directly (via
using Conda followed by Conda.add etcetera).
) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'sklearn'")
Stacktrace:
[1] pyimport(::String) at /home/ezio/.julia/packages/PyCall/ttONZ/src/PyCall.jl:544
[2] pyimport_conda(::String, ::String, ::String) at /home/ezio/.julia/packages/PyCall/ttONZ/src/PyCall.jl:702
[3] pyimport_conda at /home/ezio/.julia/packages/PyCall/ttONZ/src/PyCall.jl:701 [inlined]
[4] import_sklearn() at /home/ezio/.julia/packages/ScikitLearn/HK6Vs/src/Skcore.jl:119
[5] top-level scope at /home/ezio/.julia/packages/ScikitLearn/HK6Vs/src/Skcore.jl:153
julia> using ScikitLearn
julia> @sk_import linear_model: LinearRegression ERROR: PyError (PyImport_ImportModule
The Python package sklearn could not be found by pyimport. Usually this means that you did not install sklearn in the Python version being used by PyCall.
PyCall is currently configured to use the Python version at:
/usr/bin/python3
and you should use whatever mechanism you usually use (apt-get, pip, conda, etcetera) to install the Python package containing the sklearn module.
One alternative is to re-configure PyCall to use a different Python version on your system: set ENV["PYTHON"] to the path/name of the python executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.
Another alternative is to configure PyCall to use a Julia-specific Python distribution via the Conda.jl package (which installs a private Anaconda Python distribution), which has the advantage that packages can be installed and kept up-to-date via Julia. As explained in the PyCall documentation, set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then, To install the sklearn module, you can use
pyimport_conda("sklearn", PKG)
, where PKG is the Anaconda package the contains the module sklearn, or alternatively you can use the Conda package directly (viausing Conda
followed byConda.add
etcetera).) <class 'ModuleNotFoundError'> ModuleNotFoundError("No module named 'sklearn'")
Stacktrace: [1] pyimport(::String) at /home/ezio/.julia/packages/PyCall/ttONZ/src/PyCall.jl:544 [2] pyimport_conda(::String, ::String, ::String) at /home/ezio/.julia/packages/PyCall/ttONZ/src/PyCall.jl:702 [3] pyimport_conda at /home/ezio/.julia/packages/PyCall/ttONZ/src/PyCall.jl:701 [inlined] [4] import_sklearn() at /home/ezio/.julia/packages/ScikitLearn/HK6Vs/src/Skcore.jl:119 [5] top-level scope at /home/ezio/.julia/packages/ScikitLearn/HK6Vs/src/Skcore.jl:153