I did something very stupid. I was copying some self written packages to the python dist-packages folder, then decided to remove one of them again by just rewriting the cp
command to rm
. Now the dist-packages folder is gone. What do I do now? Can I download the normal contents of this folder from somewhere, or do I need to reinstall python completely. If so - is there something I need to be careful about?
The folder I removed is /usr/local/lib/python2.7
so not the one maintained by dpkg
and friends.
I guess you are using a debian based distribution (ubuntu or similar). If so, you have to reinstall all python packages. You should be able to get most of them "automatically" by calling:
sudo dpkg --get-selections | grep -E "^python" | grep install | cut -f1 | xargs apt-get --reinstall -y install
Hope this helps. If you want to see which packages will be reinstalled, just call the first part of the piped commands:
sudo dpkg --get-selections | grep -E "^python"
Finally you should consider to use virtualenv or anaconda instead of installing or copying your own packages to dist-packages. If you don't want that, you could copy the packages to site-packages instead of dist-packages to seperate them from the distribution packages.