To execute a python script in a bash script you need to call the same command that you would within a terminal. For instance

> python python_script.py var1 var2

To access these variables within python you will need

import sys
print(sys.argv[0]) # prints python_script.py
print(sys.argv[1]) # prints var1
print(sys.argv[2]) # prints var2
Answer from iamthedrake on Stack Overflow
🌐
Medium
medium.com › @evaGachirwa › running-python-script-with-arguments-in-the-command-line-93dfa5f10eff
Running Python script with Arguments in the command line | by Eva Mwangi | Medium
April 22, 2023 - Requiring the inputs to be defined explicitly makes it easy to get arguments with little chance to error. There are no assumptions of which value matches which argument based on position. ... Script that adds 3 numbers from CMD optional arguments: -h, --help show this help message and exit --num1 NUM1 Enter third number --num2 NUM2 Enter second number --num3 NUM3 Enter first number · default The default value will be used any time an argument is not provided.
Discussions

How to run a Python script on Linux? - Stack Overflow
I'm a Windows user. I'm currently working on a Linux Mint machine. I tried running a python script the same way I would on Windows: I created a myscript.py file on the desktop and double clicked it... More on stackoverflow.com
🌐 stackoverflow.com
How to run a python file taken as a parameter in a shell script? - Unix & Linux Stack Exchange
I have a basic script called script.sh which will take 3 parameters, each a python file. I need to run these programs within script.sh. I have #! usr/bin/env python3 for my first line, and I've tr... More on unix.stackexchange.com
🌐 unix.stackexchange.com
February 23, 2020
Shell Script: Execute a python program from within a shell script - Stack Overflow
I've tried googling the answer but with no luck. I need to use my works supercomputer server, but for my python script to run, it must be executed via a shell script. For example I want job.sh to More on stackoverflow.com
🌐 stackoverflow.com
call shell script with arguments in python
The arguments need to be a list, not a single string. More on reddit.com
🌐 r/learnpython
14
8
July 23, 2018
People also ask

Can I run Python scripts within a virtual environment?
Yes, after activating the virtual environment, you can run your Python scripts within this isolated environment. This ensures that your project’s dependencies are contained and do not interfere with other projects or the system-wide Python installation.
🌐
mentorsol.com
mentorsol.com › home › python › how to run python script in terminal? updated guide 2025
How To Run Python Script In Terminal? Updated Guide 2025
How can I avoid installing Python libraries globally?
For those who prefer not to install libraries globally, setting up a virtual environment is an excellent solution. Virtual environments allow you to create isolated environments for your projects, each with its own set of installed libraries and Python versions. This way, you can work on multiple projects with different dependencies without conflicts.
🌐
mentorsol.com
mentorsol.com › home › python › how to run python script in terminal? updated guide 2025
How To Run Python Script In Terminal? Updated Guide 2025
What are virtual environments in Python?
Virtual environments are isolated environments that allow you to manage dependencies for different projects separately. Each virtual environment has its own set of installed libraries and can have different Python versions, preventing conflicts between project dependencies.
🌐
mentorsol.com
mentorsol.com › home › python › how to run python script in terminal? updated guide 2025
How To Run Python Script In Terminal? Updated Guide 2025
🌐
Tutorialspoint
tutorialspoint.com › python › python_command_line_arguments.htm
Python - Command-Line Arguments
C:\Python311>python parser1.py C:\Python311>python parser1.py -h usage: parser1.py [-h] sample argument parser options: -h, --help show this help message and exit · The second command line usage gives −help option which produces a help message as shown. The −help parameter is available by default. Now let us define an argument which is mandatory for the script to run and if not given script should throw error.
🌐
AskPython
askpython.com › home › python and bash integration in linux: a step-by-step guide
Python and Bash Integration in Linux: A Step-by-Step Guide - AskPython
April 10, 2025 - Replace arg1 and arg2 with the desired values you want to pass as arguments to your Python script. Here in this example, we pass values as 2 and 3. ‘./run_pyscript.sh‘ executes the Bash script with values 2 and 3. Gives output as the sum ...
🌐
LinuxConfig
linuxconfig.org › home › how to use a bash script to run your python scripts
How to Use a Bash Script to Run Your Python Scripts
September 21, 2025 - We can pass arguments to a Python script from a bash script by specifying them after the Python script file name when using the python command. The arguments will be accessible within the Python script through the sys.argv list.
Find elsewhere
🌐
Python
docs.python.org › 3 › using › cmdline.html
1. Command line and environment — Python 3.14.4 documentation
-I option can be used to run the script in isolated mode where sys.path contains neither the script’s directory nor the user’s site-packages directory. All PYTHON* environment variables are ignored, too. Raises an auditing event cpython.run_file with argument filename.
🌐
vteams
vteams.com › blog › how-to-run-a-python-script-in-terminal
How to Run a Python Script in Terminal Step by Step Guide
April 7, 2025 - You can run Python scripts as executables, call specific functions with command line arguments, and handle various scenarios effectively. To execute a Python script, first open a terminal, then navigate to the directory where the script is located, and finally, run the script using the ‘python’ command followed by the script’s name. On Linux, consider using python3 to ensure you’re using Python 3.
🌐
OpenSourceOptions
opensourceoptions.com › how-to-pass-arguments-to-a-python-script-from-the-command-line
How to Pass Arguments to a Python Script from the Command Line – OpenSourceOptions
The argv member of sys (sys.argv) will store all the information in the command line entry and can be accessed inside the Python script. Python’s getopt module can also be used to parse named arguments. Let’s go through some examples. To follow these examples, you’ll need to have Python installed on your system. If you don’t have Python installed, you can follow the tutorial in my FREE course to get you set up with an easy, reliable installation.
🌐
MentorSol
mentorsol.com › home › python › how to run python script in terminal? updated guide 2025
How To Run Python Script In Terminal? Updated Guide 2025
June 20, 2025 - Executable Scripts: Add shebang ... Open script, use integrated terminal with python. Command Line Arguments: Use argparse for handling arguments....
Price   $$$
Address   28-E PIA, ECHS, Block E Pia Housing Scheme, 54770, Lahore
🌐
Stack Exchange
unix.stackexchange.com › questions › 569293 › how-to-run-a-python-file-taken-as-a-parameter-in-a-shell-script
How to run a python file taken as a parameter in a shell script? - Unix & Linux Stack Exchange
February 23, 2020 - #!/bin/bash CLAString=$@ #Copying the CL arguments to a string varlen=${#CLAString} #finding the no of CL args if [[ $varlen -gt 0 ]] #if no of CL args is not zero then python ${1}.py # run first CLA python script fi ... Find the answer to your question by asking. Ask question ... See similar questions with these tags.
🌐
LabEx
labex.io › tutorials › python-how-to-execute-scripts-with-parameters-418940
How to execute scripts with parameters | LabEx
Learn essential Python script parameter techniques, explore command-line argument parsing, and master script execution with flexible input management strategies.
🌐
Altcademy
altcademy.com › blog › how-to-run-a-python-script-in-linux
How to run a Python script in linux - Altcademy.com
June 13, 2023 - Congratulations! You now know how to run Python scripts in Linux, use command-line arguments, and schedule your scripts using cron jobs. With these skills, you can automate tasks, create useful tools, and build powerful applications using Python and Linux.
🌐
Medium
medium.com › @nawazmohtashim › call-python-script-from-bash-909afd5248a3
Call Python Script from Bash. In the world of software development… | by Mohd Mohtashim Nawaz | Medium
December 21, 2023 - To make our Bash script more dynamic, we can pass arguments to the Python script based on user input or other runtime conditions.
🌐
GeeksforGeeks
geeksforgeeks.org › command-line-arguments-in-python
Command Line Arguments in Python - GeeksforGeeks
Note: As a default optional argument, it includes -h, along with its long version --help. Example 1: Basic use of argparse module. ... Example 2: Adding description to the help message. ... # Python program to demonstrate # command line arguments import argparse msg = "Adding description" # Initialize parser parser = argparse.ArgumentParser(description = msg) parser.parse_args()
Published   March 17, 2025
🌐
Baeldung
baeldung.com › home › scripting › how to call python from a bash script
How to Call Python From a Bash Script | Baeldung on Linux
March 18, 2024 - We’ve used the EOF marker within the sample_task.sh Bash script to mark the start and end of the here-document. The Python code is the same as that of the standalone script discussed earlier. Then, in the last line, we call the Python interpreter over the count_filter.py script while passing the path to the CSV file as an argument.