Uninstall python eggs that you installed using setup.py | MyThinkPond

python_logoIn Python, most libraries are available using the pip install process. But for cases, where you are distributing code to be installed in customer sites where you may or may not have a internet connection to the pip libraries, you resort to the legacy setup.py process.

When you install using the setup.py process, the setup.py copies it’s collection of python files to the site-packages folder for your python virtual-environment. On a CentOS, this might be a location under (/usr/lib/python2.7/site-packages/) directory. This may also write it’s files to other locations such as config files and resource files.

Once installed and if you decide you want to uninstall or upgrade the package or egg, it’s hard to identify all the files that this egg touched. Within the setup.py process there are some other options that can help you in identifying the python files that are placed in these locations. Here is an example of how you can identify the files and remove the files before upgrading.


# To note down the list of files that are installed
python setup.py install --record egg-files.txt
# To remove those files you can do the following using the egg-files.txt
cat egg-files.txt | xargs rm -rf
# This would remove the individual files but will leave the ".egg-info" directory and other artifacts under site-packages. 
# You can remove the package directories manually

On the other hand, if you have access to pip then you can leverage “pip freeze” options (read more here) along with “pip uninstall” option (read more here).

Cheers.

Venkatt Guhesan avatar
About Venkatt Guhesan
Enterprise Software Architect currently working at DataDirect Networks developing a highly scalable monitoring solution called DDN Insight. My passions include all things Open Source including Linux (CentOS, Red Hat, Gentoo, Open Stack, Docker & Ubuntu), embedded ARM processors and microcontrollers (Arduino, UDOO, Cubieboard, BeagleBoard, OnionIO, TI's Zigbee). Coming from an Electrical and Computer Engineering background, working in developing and designing enterprise - distributed, highly scalable software requires a unique set of software skills with a good understanding of the hardware. This makes his work challenging and interesting. In his free time, he spends his time with his family and two children. He also enjoys researching on topics including - world ancient history and yoga. Visit the 'About' section for more details.
comments powered by Disqus