【发布时间】:2018-09-27 17:07:55
【问题描述】:
我在一台用于自动测试的特定 OSX 机器上遇到问题,即 os.listdir 引发 OSError。
有趣的是:
os.path.exists("/Volumes/label_of_mounted_drive") -> True
os.path.isdir("/Volumes/label_of_mounted_drive") -> True
但是
os.listdir("/Volumes/label_of_mounted_drive") -> OSError ([Errno 2] No such file or directory)
路径的统计数据是
posix.stat_result(st_mode=16877, st_ino=1, st_dev=939524119, st_nlink=2, st_uid=502, st_gid=20, st_size=68, st_atime=1523980718, st_mtime=1523980718, st_ctime=1523980718)
驱动器已安装、可见并可在 finder 中使用。我可以通过终端列出它。我什至可以通过单独的 python 进程列出它(例如调用 subprocess 和 'python'、'-c'、'import os; print os.listdir("the_path_here")')
更有趣的是,它在 2 天前还在工作,现在停止了*。
此外 - 在终端中运行 python - listdir 在这个特定路径上工作,通过nosetests / unittests 运行测试 - listdir 已损坏。
现在这不是这台特定机器上第一次发生这种情况。上次我只是重新安装了整个系统并修复了它。 现在 - 我也打算这样做 - 但此时 我非常好奇是什么原因造成的。
有什么想法吗?
*在我从 virtualenv 切换到 pyenv-virtualenv 后它停止工作。但是经过一段时间和许多其他尝试后,我卸载了所有 brew 包和 brew 本身,创建了新用户,删除了旧用户,从头开始在新用户上安装了 brew 和 python,然后回到简单的 virtualenv,一切都没有成功: (
机器设置是:
- 塞拉利昂 10.12.6
- 酿造
- python@2
- xcode 9.2
- 一些已安装的库是:
- 酿造:zlib、libjpeg
- python:matplotlib、Pillow、lxml、pyobjc
【问题讨论】:
标签: python macos matplotlib operating-system listdir