export FLASK_APP=./index.py invalid syntax

Issue

Getting a syntax error on when I run this as a bash file, here is code:

#!/bin/bash
export FLASK_APP=./index
source $(pipenv --venv)/bin/activate
flask run -h 0.0.0.0

The error is:

 python bootstrap.sh                                                                                                                                                                                                                     ─╯
  File "bootstrap.sh", line 2
    export FLASK_APP=./index
       ^
SyntaxError: invalid syntax

This runs fine on my linux box, but is giving me a syntax error running on my work mac. I can run the command in the shell fine, what am I doing wrong that won’t allow this to run from a bash script?

Solution

It looks like you’re trying to run the shell script with python?

python bootstrap.sh

Run it with shell instead:

$ sh bootstrap.sh or $ ./bootstrap.sh

Answered By – djnz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published