python - 名称中带有波浪号的 Anaconda/Python 站 pip 包子文件夹 - 它们是什么?

标签 python pip anaconda python-packaging

今天去改了matplotlib的配置。搜索 matplotlibrc 发现我有两个:

Screenshot of search results, with two entries: <code>C:\Anaconda3\Lib\site-packages\~-tplotlib\mpl-data</code> and <code>C:\Anaconda3\Lib\site-packages\matplotlib\mpl-data</code>

查看site-packages 文件夹,我发现很多包的名称中都有波浪号:

Windows Explorer screenshot showing that site-packages contains many other folders starting with a <code>~</code> symbol, like <code>~klearn</code> and <code>~yximport</code>

  • ~klearnsklearn ,但是还有一个 sklearn
  • ~atplotlib 也是matplotlib,更改日期是2018-11
  • ~-tplotlib的更改日期是2019-3.15
  • matplotlib的更改日期是2019-3.28(我最近更新了matplotlib)

这些波浪线名称包有什么用?我可以安全地删除它们吗?

最佳答案

您是否可能使用 pip 安装了那些特定的软件包?如果是这样,那么损坏的目录可能是 pip 在卸载包时创建的临时目录(或者当它卸载包以准备更新包时)。

我仔细研究了 pip 源代码,发现 this snippet 显然只用于卸载包:

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"

    ...

如果这就是这些文件的内容,那么您可以安全地删除它们。

关于python - 名称中带有波浪号的 Anaconda/Python 站 pip 包子文件夹 - 它们是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55565760/

相关文章:

python - 我可以在 AssertionError 上强制调试 python 吗?

python - opencv TypeError: 'interpolation'是此函数的无效关键字参数

python - 有条件地让 pip 根据平台选择不同的版本

python - conda list 在安装 PyTortch 后返回运行时错误 Path not Found

python - (Python : discord. py)错误 : Could not build wheels for multidict, 使用 PEP 517 且无法直接安装的 yarl

python-2.7 - ImportError:无法导入名称 goto Python

python - Apache + mod_wsgi - Python 不加载已安装的模块

python - 在 OSX 上调用 python 和 Spyder 的方法

python - `conda env remove` 挂起 16 小时,我有什么选择?

python - 字典或 If 语句,Jython