Sunday, November 3, 2019

Erik Marsja: Three Easy Methods to Upgrade Pip to the Latest Version

The post Three Easy Methods to Upgrade Pip to the Latest Version appeared first on Erik Marsja.

In this tutorial, we will learn how to upgrade pip. This may be handy, if we, for instance, are working with old Python environments, This, in turn, may leed to that we need to upgrade pip to the latest version.

In this post, we will use pip, conda (Anacondas package manager), and Anaconda Navigator to upgrade pip.

How to Upgrade Pip

In this section, we will learn how to get the latest version of pip using the three previously mentioned methods. Moreover, in the first subsections, we are going to use Windows Command Prompt as well as pip. Of course, we could also use Windows PowerShell to run the commands we need to upgrade pip. Find out how to open the command prompt here.

How to Check Pip Version

First, before learning how to upgrade pip we are going to answer the question “what version of pip do I have?” Now, to get the output, as in the image above, we can start up the Windows Command Prompt and type pip --version. In the Python environment, we have pip 19.2.3 installed. Note, a step-by-step guide will show how to open Windows Command prompt.

Update pip Using pip

Now, we are going to answer the question “how to update Python pip?” and we are going to start by using pip to update pip. To upgrade pip, we open up the command prompt and type the following code:

pip install --upgrade pip

If we now type pip --version again we will see that we have the latest version of pip installed:

3 Steps to Update Pip using Pip

Now, here’s a more detailed description of how to update pip using pip. In the first step, we are going to open up the command prompt:

1) Open the command prompt

In the search box, to the bottom left, type “Command Prompt”.

2) Right-click on the Command Prompt app

The next thing we are going to do is to click on the command prompt app. We make sure to right-click on it and run it as administrator. This way we’ll avoid any permission issues.

3) Upgrade pip

Now, that we the command prompt up and running we are ready to update pip. In this example, we are going to upgrade pip using pip:

pip install --upgrade pip

Upgrade Pip using Conda

In this section, we are going to learn how to upgrade pip using conda package manager. This may come in handy as many of us have installed Python using the scientific Python distribution Anaconda. That is, here we find the answer to the question “How do I upgrade PIP on Anaconda prompt?” Now, we are going to update pip by using three simple steps.

1) Search for the Anaconda Prompt.
First, before running conda to update pip we are going to start the Anaconda Prompt. This is simple, we just type “anaconda prompt” where we typed “Command Prompt” earlier:

2) Open the Anaconda Prompt.
Second, we are going to click on the icon for the Anaconda Prompt and run it as administrator (right-click).

3) Upgrade pip!
Finally, we can update pip using conda. Now, this is very simple. All we need to do is write the following command to update pip:conda upgrade -c anaconda pip.

That was it, now we know how to upgrade pip without using pip! It was easy. Note, if your Anaconda Python distribution is in the system path, we could also have updated pip by opening the Windows Command Prompt and using the same commands as above.

Upgrade Pip Using Anaconda Navigator

In this final section, we are going to learn how to update pip using Anaconda Navigator. Using this method to upgrade pip is good if we don’t want to use the command prompt but rather use a GUI.

First, we start up the Anaconda Navigator. It can be done by typing “Anaconda Navigator” in the search box, in the lower-left corner (see the examples above). We just need to click on “Environments” on the left part of Anaconda Navigator. After this, we can scroll down to find pip:

Second, when we have found pip we click on the green check-mark as we can see that there is an update available for pip:

Third, after we have clicked on the green mark we will get a drop-down menu. Obviously, as we are going to upgrade pip we will choose “Mark for update”:

Finally, we are ready to update pip using Anaconda Navigator. In the bottom right corner, there will now be to buttons. We are going to press the green button with the text “Apply”:

Voila! The package pip, or any other Python package, should now be upgraded to the latest version! Updating pip using Anaconda Navigator was quite easy as well.

Conclusion

In this post, we have learned how to upgrade pip to the latest version. The examples, on how to update Pip, were conducted under Windows 10. However, as pip (and conda) has the same functionality on Linux machines we could probably use them as well (e.g., using the sudo command). In conclusion, we have learned how to update pip using pip, using conda (i.e., Anaconda Prompt), and Anaconda Navigator.

The post Three Easy Methods to Upgrade Pip to the Latest Version appeared first on Erik Marsja.



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...