Calmcode - virtualenv: pip


1 2 3 4 5 6 7 8 9 10

If we want to install fastapi and pandas we can run;

python -m pip install fastapi pandas

To install a specific version we could run;

python -m pip install fastapi==0.50.0

But we can also put our requirements in a file, like so:


Note that pip will install the most recent version of a package unless we tell it not to. In this example we're saying that fastapi needs to be set exactly while numpy needs to be at least version 1.17.

Given such a file, say requirements.txt, then we can also install everything by running;

python -m pip install -r requirements.txt

If you wanted to check which python packages are installed you could run

python -m pip freeze

And if you want to narrow it down you can pipe the output of this command to grep to narrow it down.

python -m pip freeze | grep fastapi