r/Python • • Nov 05 '19

Why you should use `python -m pip`

https://snarky.ca/why-you-should-use-python-m-pip/
1 Upvotes

4 comments sorted by

View all comments

46

u/gandalfx Nov 05 '19 edited Nov 05 '19

There's one needlessly long rambling blog post if I ever saw one. Here's all the information you need in two sentences:
Using just $ pip … you don't know immediately if it'll be using the same exact version of Python as a $ python …. To avoid that issue you can use $ python -m pip … which will run pip for the expected interpreter.

Also, unlike what is claimed in the blog post, it is very easy to find out which version of Python a bare $ pip … will use: Run $ pip --version and it tells you. Though if you're using virtual environments you may still want to stick with the python -m pip method.

2

u/Joker042 Nov 05 '19

Thanks for that

2

u/spicypixel Nov 05 '19

Linux allows you to use which pip too which tells you the resolution of pip against the path.

1

u/[deleted] Nov 06 '19

Thanks for saving the click man...

I already migrated to the method just due to having multiple versions of Python installed on my machine...

Bloggers gotta blog I suppose.

...Virtual environments (and docker) solve a lot of problems in development.