环境错误[ERRNO39]“错误;“目录不为空”;pip在python3中安装或更新包时

环境错误[ERRNO39]“错误;“目录不为空”;pip在python3中安装或更新包时,python,pip,Python,Pip,在这里发布Q&A,因为还没有关于此类错误的帖子,以及web搜索上的其他链接导致未解决的gihub问题。下面是我在虚拟python环境中更新的一个包: (py36) $ pip install tornado -U Collecting tornado Downloading https://files.pythonhosted.org/packages/03/3f/5f89d99fca3c0100c8cede4f53f660b126d39e0d6a1e943e95cc3ed386fb/tor

在这里发布Q&A,因为还没有关于此类错误的帖子,以及web搜索上的其他链接导致未解决的gihub问题。下面是我在虚拟python环境中更新的一个包:

(py36) $ pip install tornado -U
Collecting tornado
  Downloading https://files.pythonhosted.org/packages/03/3f/5f89d99fca3c0100c8cede4f53f660b126d39e0d6a1e943e95cc3ed386fb/tornado-6.0.2.tar.gz (481kB)
    100% |████████████████████████████████| 491kB 476kB/s 
Building wheels for collected packages: tornado
  Building wheel for tornado (setup.py) ... done
  Stored in directory: /home/nikhil/.cache/pip/wheels/61/7e/7a/5e02e60dc329aef32ecf70e0425319ee7e2198c3a7cf98b4a2
Successfully built tornado
Installing collected packages: tornado
  Found existing installation: tornado 5.1.1
    Uninstalling tornado-5.1.1:
      Successfully uninstalled tornado-5.1.1
Could not install packages due to an EnvironmentError: [Errno 39] Directory not empty: '/mnt/STUFF/py36/lib/python3.6/site-packages/~ornado'

那么如何解决这个问题呢?

检查错误消息中突出显示的实际文件夹:

/mnt/STUFF/py36/lib/python3.6/site-packages/~ornado

我发现还有另外一个
.fuse hidden…
文件,通常是在运行时我在文件夹中使用Geany(文本编辑器)时,在我按文件保存并刷新文件夹后,这些文件就会消失。不知何故,这样一个文件也在这里创建,但从未被删除。请注意,这可能是我的操作系统的错误,而不是Geany的-IDK。无论如何,我自己删除了该文件并运行了升级命令,这次没有出现任何错误。

有一个类似的问题,即使用wheel(
python setup.py bdist_wheel
)创建我自己的python包的内置分发存档时,会产生相同的错误消息。当我关闭了我想要从中生成构建分发版的包的所有打开的文件(即,我关闭了文本编辑器)后,问题就解决了

由于这是相同的错误和类似的解决方案,但发生在非常不同的情况下,我创建了自己的堆栈溢出问题