Sunday, July 28, 2024

Programming Scripting Automation: Auto Upgrade Pip Modules Python

Auto Upgrade PIP Modules V.1.0.0.

    Hallo! Welcome to my blog. I have some new program that I've made myself here, and the program helps me a lot when I need to upgrade all my python modules all at a time. if you want to upgrade specific module it is fine using Terminal (Linux) or CLI (Windows) but if you want to upgrade many modules, its like tiresome. I want to show you how to make this simple program.


Using Class For Import Flexibility

In my daily programming I always use class even for small program like this one, because if someday I need to reuse the functions I need only to put it in current directory of my program and import it as module.

Class of AutoUpgradePIP.

I use logging to record all errors encountered during the running and upgrading of modules, so that people like me can identify which packages have errors during the upgrade process.


First Upgrade The PIP

Upgrade the PIP before we upgrade the packages.

Upgrading pip before upgrading modules is generally recommended for a few reasons improved features and bug fixes, compatibility with latest packages, security enhancements, dependency resolution.

In summary, keeping pip updated helps in maintaining a smoother and more secure package management experience.


Different Method To Achieve Same Goal

In this picture of codes we can understand why I use two functions to achieve one goal.

Different method function base on needs.


Running The Program

Running the program from Windows.

I test it in Linux and Windows, both are fine ready to use:

Right now while the program is automatically upgrading the pip modules, I can do another task and when program finished the upgrade, if there are errors, we can see it in log (this log file is from my Linux machine):

The log of errors encountered when it was upgrading the pip modules (this log file is from my Linux machine).

 

End...

That's all for today that I can share to you. Thank you for visiting my blog and have a great day!

P.S
When I program, I use interchangeable operating systems simultaneously between a Windows virtual machine and a Linux host machine. If the switching images caused any confusion, I apologize. Thank you for your understanding and for visiting.