juliapkg: Julia Version and Package Manager for Python
JuliaPkg is a Python library that allows managing Julia installations and Julia packages directly from within Python. It provides functions to add specific Julia versions, install Julia packages, and ensure they are available for use, often in conjunction with PyJulia (the `julia` Python package) for direct interaction. It aims to simplify the setup of Julia environments for Python users. The current version is 0.1.23, and it's actively maintained with regular releases.
Common errors
-
Julia executable not found. Please install Julia.
cause `juliapkg` could not find or successfully install a Julia executable for the requested version, or a previously managed Julia installation became inaccessible.fixEnsure you have called `juliapkg.add_julia()` with a valid version (or no arguments for the latest stable) and then `juliapkg.install()`. Check network connectivity if it's a new installation. If a specific version is requested, verify it exists and is supported. -
ERROR: LoadError: ArgumentError: Package XXX not found in current path.
cause A Julia package was added via `juliapkg.add("XXX")` but `juliapkg.install()` was not called afterward, or the Julia environment wasn't properly re-activated, or the package failed to install.fixAfter adding any Julia package with `juliapkg.add()`, always call `juliapkg.install()` to ensure the package is downloaded and configured in the Julia environment. If the error persists, check the output of `juliapkg.install()` for any specific Julia package installation errors.
Warnings
- gotcha Always call `juliapkg.install()` after adding new Julia versions or packages. Forgetting this step will result in the Julia environment not being updated, and newly added items will not be available.
- gotcha When using `juliapkg` with `PyJulia` (the `julia` Python package), ensure `PyJulia` is configured to use the Julia installation managed by `juliapkg`. By default, `PyJulia` will try to find a Julia executable in your PATH or via `JULIA_PATH` / `JULIA_DEPOT_PATH` environment variables. `juliapkg` sets up the environment variables correctly for its managed Julia, but explicit setup might be needed if you have multiple Julia installations.
- gotcha Network connectivity issues can prevent Julia versions or packages from being downloaded and installed. This can manifest as stalled downloads or connection errors during `juliapkg.add_julia()` or `juliapkg.install()`.
Install
-
pip install juliapkg
Imports
- juliapkg
import juliapkg
- add_julia
juliapkg.add_julia(...)
- add
juliapkg.add(...)
- install
juliapkg.install()
Quickstart
import juliapkg
import os
# Add a specific Julia version (e.g., 1.9.4).
# If not present, juliapkg will download and install it into a managed location.
juliapkg.add_julia("1.9.4")
# Add a Julia package to the managed environment.
juliapkg.add("Example")
# Install all added Julia versions and packages.
# This ensures they are available in the Python-managed Julia environment.
juliapkg.install()
print("Julia 1.9.4 and 'Example' package are installed and ready.")
print("To use them, typically you would interface with PyJulia:")
print(" from julia import Julia")
print(" jl = Julia()")
print(" jl.eval('using Example; Example.hello()')")