Julia/Python bridge with IPython support enabling seamless interoperability between Python and Julia programming languages.
npx @tessl/cli install tessl/pypi-julia@0.6.0A comprehensive Python library that enables seamless interoperability between Python and Julia programming languages. PyJulia allows Python developers to call Julia functions directly from Python code, leverage Julia's high-performance numerical computing capabilities within Python workflows, and provides automatic type conversion between Python and Julia data structures.
pip install juliaimport juliaFor the main Julia interface:
from julia import JuliaFor accessing Julia modules directly:
from julia import Base, MainFor IPython/Jupyter magic commands:
%load_ext julia.magicimport julia
# Install required Julia packages (run once)
julia.install()
# Create Julia interface
jl = julia.Julia()
# Access Julia's Base module
from julia import Base
# Call Julia functions
result = Base.sind(90) # Sin in degrees
print(result) # 1.0
# Execute Julia code directly
jl.eval('println("Hello from Julia!")')
# Access Julia variables
jl.eval('x = [1, 2, 3, 4, 5]')
x = jl.eval('x')
print(x) # [1, 2, 3, 4, 5]
# Use Julia's powerful array operations
import numpy as np
arr = np.array([1.0, 2.0, 3.0])
jl_result = jl.eval('sum(x -> x^2, [1, 2, 3])')
print(jl_result) # 14.0PyJulia implements a multi-layered architecture for Python-Julia interoperability:
Julia class provides easy-to-use Python API with automatic type conversionfrom julia import Base, Main)LibJulia class provides direct access to Julia's C API for advanced usersjulia-py and python-jl executables for command-line integrationThis design enables both casual scientific computing users and performance-critical applications to leverage Julia's capabilities from Python environments.
Primary interface for executing Julia code from Python, including runtime initialization, module importing, function calling, and automatic type conversion between Python and Julia data structures.
class Julia:
def __init__(self, runtime=None, jl_init_path=None, **kwargs): ...
def eval(self, code: str): ...
def using(self, module_name: str): ...
def install(julia="julia", color="auto", python=None, quiet=False): ...
# Direct module access
from julia import Base, MainMagic commands, code completion, and interactive development features for Jupyter notebooks and IPython environments, including Revise.jl integration for automatic code reloading.
class JuliaMagics:
def julia(self, line, cell=None): ... # Line and cell magic
# Magic command usage in Jupyter
%julia code
%%julia
multi-line
codeDirect access to Julia's C API for advanced users who need fine-grained control over the Julia runtime, memory management, and performance-critical operations.
class LibJulia:
def __init__(self, **kwargs): ...
def eval_string(self, code: str): ...
def call(self, func, *args): ...
def get_libjulia(): ...
def set_libjulia(libjulia): ...Utilities for PyCall.jl installation, system image building, testing infrastructure, and development workflow support including PyCall rebuild and Julia executable management.
def install(julia="julia", color="auto", python=None, quiet=False): ...
def build_pycall(julia="julia", python=sys.executable, **kwargs): ...
def build_sysimage(output, julia="julia", script=None, debug=False): ...Command-line utilities for running Julia through PyJulia (julia-py) and Python within Julia processes (python-jl), providing seamless integration for shell-based workflows.
# Console scripts (available after installation)
# julia-py [julia-options] [script] [script-args]
# python-jl [python-options] [script] [script-args]class JuliaError(Exception):
"""Wrapper for Julia exceptions raised during execution."""
class JuliaNotFound(Exception):
"""Raised when Julia executable cannot be found."""
class UnsupportedPythonError(Exception):
"""Raised for unsupported Python configurations."""
class JuliaModule:
"""Represents a Julia module accessible from Python."""
class JuliaMainModule(JuliaModule):
"""Special Julia Main module with assignment support."""