slimgroup / JUDI.jl

Julia Devito inversion.
https://slimgroup.github.io/JUDI.jl
MIT License
98 stars 31 forks source link

Is `pyrevolve` new dependency of JUDI? #205

Closed kerim371 closed 1 year ago

kerim371 commented 1 year ago

Hi,

I recently installed JUDI 3.3.8 and when importing it I get error:

using JUDI
ERROR: InitError: PyError (PyImport_ImportModule

The Python package interface could not be imported by pyimport. Usually this means
that you did not install interface in the Python version being used by PyCall.

PyCall is currently configured to use the Python version at:

/home/kerim/python/python-3.9/bin/python

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the interface 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 interface module, you can use `pyimport_conda("interface", PKG)`,
where PKG is the Anaconda package that contains the module interface,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'pyrevolve'")
  File "/home/kerim/.julia/packages/JUDI/JEsVr/src/pysource/interface.py", line 5, in <module>
    from pyrevolve import Revolver

Stacktrace:
 [1] pyimport(name::String)
   @ PyCall ~/.julia/packages/PyCall/ilqDX/src/PyCall.jl:558
 [2] __init__()
   @ JUDI ~/.julia/packages/JUDI/JEsVr/src/JUDI.jl:170
 [3] _include_from_serialized(path::String, depmods::Vector{Any})
   @ Base ./loading.jl:696
 [4] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String)
   @ Base ./loading.jl:782
 [5] _require(pkg::Base.PkgId)
   @ Base ./loading.jl:1020
 [6] require(uuidkey::Base.PkgId)
   @ Base ./loading.jl:936
 [7] require(into::Module, mod::Symbol)
   @ Base ./loading.jl:923
during initialization of module JUDI

is pyrevolve new dependency of JUDI? Before that to use JUDI it used to be enough to install devito. Am I right I should also preinstall pyrevolve?

mloubout commented 1 year ago

pyrevolve is a dependency of devito that is now optional. JUDI however stills installs it, but it might not be installed if you install devito yourself instead of letting JUDI install it.

See Here That JUDI 3.3.8 does install it as an extra dependency

kerim371 commented 1 year ago

Oh, thank you! didn't know that JUDI preinstalls devito.

mloubout commented 1 year ago

JUDI only preinstalls it if it doesn't find it, so if you install it yourself JUDI assumes it's installed with all needed dependencies.

kerim371 commented 1 year ago

I think for me the best solution is when I manually build PyCall using my python and then I install JUDI and JUDI handles its dependencies (like devito) by itself.

Am I right that this workflow may be written in such way (in julia repl) ? :

ENV["PYTHON"]="/path/to/my/python"

using Pkg
Pkg.add("PyCall")
Pkg.build("PyCall")
Pkg.add("JUDI")
mloubout commented 1 year ago

Yes. You might need Pkg.build("JUDI") as well after the add

kerim371 commented 1 year ago

Ok, good to know!