How can I revert changes done to python packages?

Viewed 5099

I'm debugging an issue on a staging, and I've added a bunch of logging statements to a 3rd party package. Once I'm done with that, I'd like to get them back to their original state. In ruby, I could do a gem pristine lib_name and that would restore the lib to it's original source code.

It might be relevant to mention that I'm modifying code that was installed with sudo pip install some_pkg.

What's the usual way of reverting any changes done to a lib?

3 Answers

I suppose you have one "requriemnt.txt" file which you want to revert back packages to:

#remove all currently installed packages
pip freeze > remove.txt
pip uninstall -r remove.txt
#re-insatll all packages 
pip install -r requriement.txt

This ensures that you also remove all unwanted packages

Related