Make sure PyCall.jl work well before installation, then
(v1.0) pkg> add https://github.com/229668880/Python.jl.git
Python.jl can work with Julia 1.0 and Python 3 on Windows.
Python.jl is only based on PyCall.jl, and help to use Python native codes freely (include plotting with matplotlib) in Julia REPL or provide Python REPL as you do in Python command-line interface. Python.jl will work properly if Pycall.jl works well with Python. It doesn't need any more installation and configuration.
Run using Python
and start Python at backend, then:
-
Julia REPL: use macro
@py python_codes
to run Python codes, or@py variable_name
to show the value of a variable in Python. Since PyCall.jl has been imported, you can embedpy"a"
in any codes to use the value ofa
which is created in Python by@py a=100
, e.g.py"a"*1000
in Julia REPL. -
Python REPL: type
Ctrl+)
in emptyjulia>
to enter Python REPL, and input any Python codes as you do in in Python command-line interface. You can switch back to Julia REPL bybackspace
. -
Transfer data between two REPL: In Julia REPL, use
a=py[:b]
to copyb
in Python toa
in Julia, andpy[:c]=d
to copyd
in Julia toc
in Python. Operations like100*py[:b]
are allowed. In Python REPL,$d+100
causes the same effect. -
Plotting: After
using Python
initializes, Python codesfrom matplotlib.pylab import *
andimport matplotlib.pyplot as plt
have been executed in Python backend,so you can plot with typingplot(randn(100))
. Plotting functionalities are only based on PyCall.jl, independent of PyPlot.jl, and let you plot freely as in IPython. Python.jl works well with Qt5, and maybe needshow()
function to display plotting window for unknown reason.
Note:
If plotting doesn't work, try to pip3 install pyqt5
and make sure Qt5 is your plotting backend in Python. If there is any unpredicted errors, try using PyCall
before your operation.
- PyCall.jl
- Any version of Python that makes PyCall.jl work properly.