Skip to main content

Running Python Code

Learn how to set up and run Python programs in SrcNexus Code Editor.

Prerequisites

Before proceeding, make sure you have set up the terminal environment in SrcNexus Code Editor.

Step 1: Install Python

Open Termux and run the following command to install Python:

apt install python

Step 2: Setup Project Folder

Since Python is installed in Termux, it is best to keep your Python projects within the Termux storage so you can easily run them.

  1. Open SrcNexus Code Editor.
  2. Tap the + (Plus) button in the bottom right corner.
  3. Choose Select from file.
  4. Scroll to the bottom and tap Add new folder.
  5. The Android system file picker will open. Tap the three dots (menu) in the top corner.
  6. Select Termux from the list.
  7. Create a new folder for your projects (e.g., CodingProjects) and open it.
  8. Tap Use this folder and allow permissions.

Now, this folder will be visible in the SrcNexus Code Editor file manager.

Step 3: Create Your Project

  1. Navigate into the Termux folder you just added in SrcNexus Code Editor.
  2. Tap the menu in the top right and create a New Folder for your specific project (e.g., my-python-app).
  3. Select this folder to open it as your workspace.
Pro Tip

If you want all future projects to be created in this folder by default, you can go to Settings and set this folder as the Default Project Location. Next time, "Create New Project" will create folders directly here.

Step 4: Write and Run Code

  1. Create a new file named main.py.
  2. Add some example code to verify everything is working:
print("Hello, SrcNexus!")
  1. Tap the Terminal icon in the top toolbar.
  2. In the terminal, run your file using python:
python main.py

You should see the output Hello, SrcNexus! printed in the terminal.