If typing this produces SyntaxError: invalid syntax:
1 | >>> pip3 install ipython |
the command was entered inside Python’s interactive prompt. pip is a shell command, not Python syntax.
Exit the prompt with exit() or the platform’s end-of-file shortcut. Then run the command in Terminal, Command Prompt, or PowerShell:
1 | python -m pip install ipython |
python -m pip is preferable to a bare pip3 because it identifies which Python installation will receive the package.
For a project, create an isolated environment first:
1 | python -m venv .venv |
Activate it using the operating system’s normal command, upgrade pip if needed, and install the dependency. In a Jupyter notebook, use the notebook-aware %pip install ipython magic rather than invoking pip as ordinary Python code.
If the command still fails outside the interpreter, read the final part of the traceback. Network failures, permissions, unsupported Python versions, and build-tool errors require different fixes; SyntaxError at the pip install words specifically indicates that a shell command was entered in a Python context.