Cap Barracudas
Cap Barracudas

Reputation: 2515

How to run a python3 script with 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 .

Upvotes: 6

Views: 14304

Answers (2)

Codemaker2015
Codemaker2015

Reputation: 15590

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
    

Upvotes: 2

Cap Barracudas
Cap Barracudas

Reputation: 2515

pm2 start app.py --interpreter python3

Upvotes: 15

Related Questions