How do you uninstall a python package that was installed using distutils?

前端 未结 12 2438
我在风中等你
我在风中等你 2020-11-30 00:36

Can you simply delete the directory from your python installation, or are there any lingering files that you must delete?

12条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 00:37

    install --record + xargs rm

    sudo python setup.py install --record files.txt
    xargs sudo rm -rf < files.txt
    

    removes all files and but leaves empty directories behind.

    That is not ideal, it should be enough to avoid package conflicts.

    And then you can finish the job manually if you want by reading files.txt, or be braver and automate empty directory removal as well.

    A safe helper would be:

    python-setup-uninstall() (
      sudo rm -f files.txt
      sudo python setup.py install --record files.txt && \
      xargs rm -rf < files.txt
      sudo rm -f files.txt
    )
    

    Tested in Python 2.7.6, Ubuntu 14.04.

提交回复
热议问题