Skip to content

Instantly share code, notes, and snippets.

@anonhostpi
Last active January 17, 2024 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonhostpi/acc624d66e4f0f8797bc4655cdbeb85a to your computer and use it in GitHub Desktop.
Save anonhostpi/acc624d66e4f0f8797bc4655cdbeb85a to your computer and use it in GitHub Desktop.
Execute Julia code in PowerShell
using namespace Python.Runtime
# winget install julia -s msstore # Julia engine
# pip install julia # PyJulia
# Import-Module Import-Package
Import-Package pythonnet
# Initialize the engine and lock CPython
[PythonEngine]::BeginAllowThreads()
[PythonEngine]::Initialize()
$gil = [Py]::GIL() # Lock
$julia = [Py]::Import("Julia")
# $julia.install() # needs to be run the first time you run PyJulia
[py]::import("julia.Base")
$julia.Base.print('Hello World!')
# Hello World!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment