AnswerBun.com

`pip install --upgrade pip` vs. `python -m pip install --upgrade pip`

Stack Overflow Asked by moth on December 17, 2020

What is the difference between:

pip install --upgrade pip

and

python -m pip install --upgrade pip

and why is python -m pip install --upgrade pip generally favoured?

3 Answers

The difference is between pip and python -m pip; the rest of the command doesn't matter. The reason to prefer the latter is that you're ensuring that the python you normally use is the one which will provide the pip module you invoke. Otherwise, there is a risk that the pip executable found in your PATH is from an unrelated or out of date Python installation; it might install packages, but your regular python invocation won't find them (because they're installed for a non-default Python).

You can also modify the second command to invoke specific Python executable names (python2.7 vs. python3.8), or even absolute paths if you might have versions with the same name installed in multiple places.

Correct answer by ShadowRanger on December 17, 2020

If i am correct, pip install --upgrade pip and python -m pip install --upgrade pip are the same unless you specify the pip or python version. The latter is preferred because it attempts to upgrade the pip associated with the specified python version (e.g. python3.7 -m pip install --upgrade pip) even if the main python version is different (python command may refer to any python version).

Answered by Shimon Cohen on December 17, 2020

The first one

pip install --upgrade pip

is to invoke pip as a command. The actual python interpretor called is not explicit. The second one is calling the python interpretor explicitly, so you know which one is called.

There should be no difference, as the __main__.py in the module and the pip script are both point to the same entry point, unless in the case that the default python is different from the one used by the pip script

Answered by adrtam on December 17, 2020

Add your own answers!

Related Questions

Why does points.sort(function(a, b){return a-b}); return -1, 0 or 1?

6  Asked on November 4, 2021 by camarellini-viberg

 

To add new row in gridview using javascript

2  Asked on November 4, 2021

   

python extract uncompressed data from 7z-file

2  Asked on November 4, 2021 by user3820991

     

JMeter get the latest file / contents from SFTP folder

1  Asked on November 4, 2021 by javaman

         

Pulling Data automatically, and keeping it Dynamic

1  Asked on November 4, 2021 by andrew-ferro

 

Dynamically consolidate columns into one column with a list of values

2  Asked on November 4, 2021 by simon-watson-sjw

 

Validity unknown symbol is not being displayed on PDF

1  Asked on November 4, 2021 by divya-agrawal

     

Use type that isn’t exported

1  Asked on November 4, 2021

 

how to return 0 if no rows

4  Asked on November 4, 2021

   

error installing laravel via composer on new pc

1  Asked on November 4, 2021 by hretic

   

The Data Flows Down in React.js

2  Asked on November 4, 2021 by fahd-dev

   

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir