You can use the '!' prefix like this:
!pip install <packagename>
The ! prefix is a short-hand for the %sc command to run a shell command.
You can also use the !! prefix which is a short-hand for the %sx command to execute a shell command and capture its output which is saved into the _ variable by default.