Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit



Failed to load latest commit information.
Latest commit message
Commit time


LPython is a Python compiler. It is in heavy development, currently in alpha stage. LPython works on Windows, macOS and Linux. Some of the goals of LPython include:

  • The best possible performance for numerical, array-oriented code
  • Run on all platforms
  • Compile a subset of Python yet be fully compatible with Python
  • Explore designs so that LPython eventually can compile all Python code
  • Fast compilation
  • Excellent user-friendly diagnostic messages: error, warnings, hints, notes, etc.
  • Ahead-of-Time compilation to binaries, plus interactive usage (Jupyter notebook)
  • Transforming Python code to C++, Fortran and other languages

And more.


LPython has been sponsored by GSI Technology. Our summer students were sponsored by Google Summer of Code via Python Software Foundation. The intermediate representation and backends are shared with LFortran, see that project for a list of sponsors.


Step 0: Prerequisites

Here is the list of requirements needed to build LPython:

  • Conda

For Windows, these are additionally required:

  • Miniforge Prompt
  • Visual Studio (with "Desktop Development with C++" workload)

Please follow the steps for your desired platform.

Step 1: Install Conda

This step involves installing Conda using a conda-forge distribution called Miniforge.

Please follow the instructions here to install Conda on your platform:

Miniforge download link (for Linux, MacOS and Windows):

Step 2: Setting up

This step involves setting up the required configuration to run the programs in LPython.


Run the below command to install binutils-dev package on Linux.

sudo apt install binutils-dev


Please follow the below steps for Windows:

  • Install Visual Studio, for example the version 2022.

    • You can download the Community version for free from:
    • After installing Visual Studio and running the Visual Studio Installer, you must install the "Desktop Development with C++" workload which will install Visual C++ Compiler (MSVC).
  • Launch the Miniforge prompt from the Desktop.

    • It is recommended to use MiniForge instead of Powershell as the main terminal to build and write code for LPython.
  • In the MiniForge Prompt, initialize the MSVC compiler using the below command:

    call "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd" -arch=x64
  • You can optionally test MSVC via:

    cl /?
    link /?

    Both commands must print several pages of help text.

Step 3: Build LPython

  • Clone LPython using the following commands

    git clone
    cd lpython

    You may also use GitHub Desktop to do the same.

Linux and MacOS

  • Create a Conda environment using the pre-existing file:

    conda env create -f environment_unix.yml
    conda activate lp
  • Generate prerequisite files; build in Debug Mode:

    # if you are developing on top of a forked repository; please run following command first
    # ./


  • Create a Conda environment using the pre-existing file:

    conda env create -f environment_win.yml
    conda activate lp
  • Generate prerequisite files; build in Release Mode:

    call build0.bat
    call build1.bat
  • Tests and examples

    src\bin\lpython examples\
    src\bin\lpython examples\ -o a.out
  • Whenever you are updating a test case file, you also need to update all the reference results associated with that test case:

    python -u --skip-run-with-dbg
  • To see all the options associated with LPython test suite, use:

    python --help


Linux or MacOS

  • Run tests:

  • Run integration tests:

    cd integration_tests
  • Troubleshooting on MacOS latest version:

    • In case of recently updated MacOS, you may get a warning like below in some test cases:

      ld: warning: object file (test_list_index2.out.tmp.o) was built for newer macOS version (14.0) than being linked (13.3)

      This leads to mismatch of hashes with expected output in some test cases, this can be resolved by updating command line tools. Below is a snippet for the same.

      git clean -dfx
      sudo rm -rf /Library/Developer/CommandLineTools # make sure you know what you're doing here
      sudo xcode-select --install


  • Run integration tests

    python --skip-run-with-dbg
  • Update reference tests

    python -u --skip-run-with-dbg

Speed up Integration Tests on MacOS

Integration tests run slowly because Apple checks the hash of each executable online before running.

You can turn off that feature in the Privacy tab of the Security and Privacy item of System Preferences > Developer Tools > > "allow the apps below to run software locally that does not meet the system's security policy."

Examples (Linux or MacOS)

You can run the following examples manually in a terminal:

./src/bin/lpython examples/
./src/bin/lpython examples/ -o expr
./src/bin/lpython --show-ast examples/
./src/bin/lpython --show-asr examples/
./src/bin/lpython --show-cpp examples/
./src/bin/lpython --show-llvm examples/
./src/bin/lpython --show-c examples/


We welcome contributions from anyone, even if you are new to compilers or to open source. It might sound daunting to contribute to a compiler at first, but please do, it is not complicated. We will help you with technical issues and help improve your contribution so that it can be merged.

To contribute, submit a Pull Request (PR) against our repository at:

and don't forget to clean your history, see example.

Please report any bugs you may find at our issue tracker: Or, even better, fork the repository on GitHub and create a PR. We welcome all changes, big or small, and we will help you make a PR if you are new to git.

If you have any questions or need help, please ask us at Zulip (project chat) or our mailinglist.

See the CONTRIBUTING document for more information.

Star History

Star History Chart