# Is there any tutorial (easy) for PyJulia?

**URL:** <https://discourse.julialang.org/t/is-there-any-tutorial-easy-for-pyjulia/99935>\
**Category:** General Usage\
**Created:** [June 6, 2023, 12:09pm UTC](https://discourse.julialang.org/t/is-there-any-tutorial-easy-for-pyjulia/99935 "2023-06-06T12:09:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cgotelli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgotelli/32/50593_2.png) [@cgotelli](https://discourse.julialang.org/u/cgotelli)\
**Post date:** [June 6, 2023, 12:09pm UTC](https://discourse.julialang.org/t/is-there-any-tutorial-easy-for-pyjulia/99935/1 "2023-06-06T12:09:59Z")

</div>

Hello!  
I have been trying to run a function available in the Julia module “GeoStats” from Python with PyJulia. However, I can’t manage to do it. Is there any tutorial showing how to make PyJulia work with the most recent versions of Julia and Python? So far I have been using [this website](https://towardsdatascience.com/how-to-embed-your-julia-code-into-python-to-speed-up-performance-e3ff0a94b6e) to learn. However, despite loading the package it is not able to find the functions inside. For example, if I run `jl.using("TextAnalysis")` it works, but after when I try to use the function **TokenDocument** by running this line `jl.eval("tokens_data = TokenDocument(data)")` it fails.

Can you please help me with this issue?

Thank you very much in advance!

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/224680_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 6, 2023, 12:14pm UTC](https://discourse.julialang.org/t/is-there-any-tutorial-easy-for-pyjulia/99935/2 "2023-06-06T12:14:03Z")

</div>

I don’t know about PyJulia but you might be interested in [GitHub - cjdoris/PythonCall.jl: Python and Julia in harmony.](https://github.com/cjdoris/PythonCall.jl) as well

---

<div class="post-metadata">

**Author:** ![cgotelli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgotelli/32/50593_2.png) [@cgotelli](https://discourse.julialang.org/u/cgotelli)\
**Post date:** [June 6, 2023, 12:27pm UTC](https://discourse.julialang.org/t/is-there-any-tutorial-easy-for-pyjulia/99935/3 "2023-06-06T12:27:41Z")

</div>

Thanks! I will try with PythonCall 😉

---

<div class="post-metadata">

**Author:** ![cgotelli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cgotelli/32/50593_2.png) [@cgotelli](https://discourse.julialang.org/u/cgotelli)\
**Post date:** [June 6, 2023, 3:15pm UTC](https://discourse.julialang.org/t/is-there-any-tutorial-easy-for-pyjulia/99935/4 "2023-06-06T15:15:27Z")

</div>

It worked! In case someone in the future has the same problem, I just installed JuliaCall following the instructions on [this website](https://cjdoris.github.io/PythonCall.jl/stable/juliacall/). Then to test it with the [Julia module](https://juliaearth.github.io/GeoStats.jl/stable/#Overview) I need, I just ran this code:

```julia
import matplotlib.pyplot as plt
import numpy as np
import scipy.ndimage
from juliacall import Main as jl, convert as jlconvert

# Importing necessary modules
jl.seval("using GeoStats")
jl.seval("using GeoStatsPlots")
jl.seval("using ImageQuilting")
jl.seval("using GeoStatsImages")
jl.seval("using Plots")
jl.seval("using ImageFiltering")
jl.seval("using ImageView")

# Example code to test
jl.seval('trainimg = geostatsimage("WalkerLake")')
jl.seval('function forward(data); img = asarray(data, :Z); krn = KernelFactors.IIRGaussian([10,10]); fwd = imfilter(img, krn); georef((fwd=fwd,), domain(data)); end')
jl.seval('dataTI = forward(trainimg)')
jl.seval('problem = SimulationProblem(domain(trainimg), :Z => Float64, 2)')
jl.seval('solver = IQ(:Z => (trainimg = trainimg,tilesize = (27,27),soft = (dataTI,dataTI)))')
jl.seval('ensemble = solve(problem, solver)')

# Recovering the Julia output from JuliaCall
m = jl.seval('ensemble.reals[1][2]')
a = np.array(m)
output = a.reshape((400,400))
plt.imshow(output)

```

Thanks for your help!
