Anaconda/Python site-packages subfolders with tilde in name - what are they?

﹥>﹥吖頭↗ 提交于 2020-01-23 07:52:26

问题


Today, I went to change the config of matplotlib. Searching matplotlibrc revealed I have two of them:

Looking at the site-packages folder, I found a lot of packages have a tilde in their name:

  • ~klearn is sklearn , but there is another sklearn .
  • ~atplotlib is matplotlib too, changed date is 2018-11
  • ~-tplotlib's changed date is 2019-3.15
  • matplotlib's changed date is 2019-3.28 (I did update matplotlib recently)

What are these tilde name packages used for? Can I delete them safely?


回答1:


Is it possible that you installed those particular packages with pip? If so, then the mangled directories are probably the temporary directories that pip creates when it uninstalls a package (or when it uninstalls a package in preparation for updating a package).

I dug through the pip source code and found this snippet which is evidently only used on uninstalling packages:

class AdjacentTempDirectory(TempDirectory):
    """Helper class that creates a temporary directory adjacent to a real one.
    Attributes:
        original
            The original directory to create a temp directory for.
        path
            After calling create() or entering, contains the full
            path to the temporary directory.
        delete
            Whether the directory should be deleted when exiting
            (when used as a contextmanager)
    """
    # The characters that may be used to name the temp directory
    # We always prepend a ~ and then rotate through these until
    # a usable name is found.
    # pkg_resources raises a different error for .dist-info folder
    # with leading '-' and invalid metadata
    LEADING_CHARS = "-~.=%0123456789"

    ...

If that's what these files are, then you can safely delete them.



来源:https://stackoverflow.com/questions/55565760/anaconda-python-site-packages-subfolders-with-tilde-in-name-what-are-they

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!