Using JuliaPy/PyJulia to interconnect with MATLAB
Hi all. I appreciate the efforts to improve Python<-> Julia interconnection.
I am using Julia 1.6.1 and Python 3.8.8 (not anaconda installation) on Windows. The interconnection is working very well.
I am able to call both core Julia and my own Julia functions within the Python terminal. Up to this point, everything is fine.
However, I am also trying to interconnect Julia --> MATLAB by means of Python because of the lack of a mature Matlab<->Julia interface, yet. This is working only if I use Julia's core functions inside my own function as following
function makeupper_byjulia(str_in) # placed in a file "juliaFunctionLib.jl"
return uppercase(str_in)
end
within Python terminal I use the above Julia function by first importing the Python function below from "juliaLibInterface.py"
def makeupper(word): # placed in a file "juliaLibInterface.py"
import julia
from julia import Main
Main.include("juliaFunctionLib.jl")
return Main.makeupper_byjulia(word)
MATLAB returns expected output in prompt when I type py.juliaLibInterface.makeupper('somestring')
When I call a Julia function which also includes other functions from Julia Modules such as DataFrames, JuMP, etc. MATLAB raises an error message as
Error using py.juliaLibInterface.function_xyz
Cannot find class 'py.PyCall.jlwrap'.
How can I resolve this issue?
Hmm... not sure what MATLAB tries to do, but I wonder if you can create a file PyCall.py (say, in the current directory) like this
from julia import Main
sample = Main.eval("""
struct Dummy
end
Dummy()
""")
jlwrap = type(sample)
and see if it can convince MATLAB that PyCall.jlwrap is a legit type. It's a horrible hack but maybe we can automate this.