Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a python3 script with pm2

Tags:

python-3.x

pm2

Pm2 default start command runs a script using python2. How can I make it run a script using python3 ? Let us say my script is called app.py .

like image 929
Cap Barracudas Avatar asked Aug 28 '26 16:08

Cap Barracudas


2 Answers

pm2 start app.py --interpreter python3
like image 150
Cap Barracudas Avatar answered Aug 30 '26 13:08

Cap Barracudas


You can run your python script with pm2 in many ways.

  • Method 1: Run the script with default python interpreter

    If you are trying to run the script using the default python interpreter installed in your machine then use the following command,

    pm2 start app.py --interpreter python3
    
  • Method 2: Run the script with interpreter installed in the virtual environment

    If you have a virtual environment configured for the script then use the following commmand,

    pm2 start app.py --interpreter venv/bin/python3
    
  • Method 3: Specify the app name

    You can specify the app name because pm2 gives the app name as the script name by default,

    pm2 start app.py --interpreter venv/bin/python3 --name genxword
    
like image 28
Codemaker Avatar answered Aug 30 '26 13:08

Codemaker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!