I am new to Python, getting Syntax Error: invalid syntax pip install Flask Flask-SQLAlchemy

pip install Flask Flask-SQLAlchemy

SyntaxError: invalid syntax

Please copy/paste the text, not screenshots of text. The visually
impaired and those of us on email do not receive screenshots. Also, we
cannot ourselves copy/paste from a screenshot to try things for
ourselves.

Tha said, it looks like you’re running the command:

 pip install Flask Flask-SQLAlchemy

at Python’s interqctive >>> prommpt. But this is a shell command, not
Python syntax.

Exit the Python prompt and get to a command prompt and retry your pip
command.

Cheers,
Cameron Simpson cs@cskk.id.au

Hello!

Running in this terminal is the Python language interpreter, and the interpreter is used to execute Python statements.

However, the function of your command is to run the pip module, not a program statement that conforms to Python syntax. If you want to run this command correctly, you just need to run it directly in the terminal(like the cmd or powershell for Windows) of the operating system (provided you add the Python path to the environment variable).

e.g.:

$ pip install Flask Flask-SQLAlchemy

Or this:

$ python3 -m pip install Flask Flask-SQLAlchemy

The -m parameter means calling the main function of the pip module, so you can also run it correctly😋.

Please see:

1 Like