GraalVM provides a Python 3.8 compliant runtime. A primary goal of the GraalVM Python runtime is to support SciPy and its constituent libraries, as well as to work with other data science and machine learning libraries from the rich Python ecosystem. At this point, the Python runtime is made available for experimentation and curious end-users. See FAQ for commonly asked questions about this implementation.
The Python runtime is not provided by default, and can be added to GraalVM with the GraalVM Updater,
gu install python
The above command will install Python from the GitHub catalog for GraalVM Community Edition users. For GraalVM Enterprise users, the manual installation is required.
GraalVM’s Python support targets Python 3.8 compatibility.
While the support is still limited, you can run simple Python commands or programs with the
graalpython [options] [-c cmd | filename]
If no program file or command is given, you are dropped into a simple REPL.
GraalVM supports some of the same options as Python 3.8 as well as some additional options to control the underlying Python runtime, GraalVM’s tools, and the execution engine. These can be viewed using the following command:
graalpython --help --help:tools --help:languages
GraalVM Python runtime comes with a tool called
ginstall which may be used to install a small list of packages known to work to some extent with GraalVM’s Python runtime.
It is recommended to always create a virtual environment first, using the standard Python module
Creating such an environment avoids any incompatible interaction with the local user’s packages that may have been
installed using a system installation of CPython:
graalpython -m venv my_new_venv source my_new_venv/bin/activate
To see the list of installable packages, run:
graalpython -m ginstall install --help
This will print a short help document including a comma-separated list of packages you can install. The installation works as described in that help document:
graalpython -m ginstall install pandas
Note that when calling Python from Java, the polyglot shell, or another language on GraalVM, you should always evaluate the piece of Python code first to make installed packages available:
For more information, continue reading to the Installing Supported Packages guide.
By default, GraalVM runs Python from a binary, compiled ahead-of-time with Native Image, yielding faster startup time and lower footprint.
Although the ahead-of-time compiled binary includes the Python and LLVM interpreters, in order to interoperate with
other languages you have to supply the
This instructs the launcher to run on the JVM instead of in Native Image mode.
Thus, you will notice a longer startup time.