Nacht Nacht - 3 months ago 18
Python Question

Why does "pip install" raise a SyntaxError?

I'm trying to use pip to install a package. I try to run

pip install
from the Python shell, but I get a
SyntaxError
. Why do I get this error? How do I use pip to install the package?

>>> pip install selenium
^
SyntaxError: invalid syntax

Answer

pip is run from the command line, not the Python interpreter. It is a program that installs modules, so you can use them from Python. Once you have installed the module, then you can open the Python shell and do import selenium.

The Python shell is not a command line, it is an interactive interpreter. You type Python code into it, not commands.

Comments