【问题标题】:OSError: [Errno 26] Text file busy on vagrant with synced_folderOSError: [Errno 26] 文本文件在 vagrant 上忙于 synced_folder
【发布时间】:2013-09-26 18:34:38
【问题描述】:

原标题:MPLCONFIGDIR .matplotlib not writeable on matplotlib import

我正在运行 pylearn2 的教程,但在导入 matplotlib.pyplot 时遇到了一些错误。一些可能不必要的信息是我在 Vagrant 生成的 VirtualBox 中运行它。我已经看到了几个类似的错误,都是关于 django 的,但我没有尝试虚拟主机,也没有空间不足。我试过以root身份运行python,虽然不安全,但它仍然不起作用。我也试过用同样的错误设置我的 MPLCONFIGDIR 变量。如果我可以提供更多信息,请告诉我。谢谢。

Traceback (most recent call last):
  File "/home/vagrant/pylearn2/pylearn2/scripts/plot_monitor.py", line 274, in <module>
    main()
  File "/home/vagrant/pylearn2/pylearn2/scripts/plot_monitor.py", line 57, in main
    import matplotlib.pyplot as plt
  File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 774, in <module>
    rcParams = rc_params()
  File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 692, in rc_params
    fname = matplotlib_fname()
  File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 604, in matplotlib_fname
    fname = os.path.join(get_configdir(), 'matplotlibrc')
  File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 253, in wrapper
    ret = func(*args, **kwargs)
  File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 475, in _get_configdir
    raise RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir.  You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "% (h, h))
RuntimeError: '/home/vagrant' is not a writable dir; you must set /home/vagrant/.matplotlib to be a writable dir.  You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored

/home/vagrant 是我的主目录,所以它是可写的,但是对于相关...

vagrant@precise64:~$ ls -ld /home/vagrant
drwxrwxrwx 1 vagrant vagrant 16384 Sep 26 17:40 /home/vagrant
vagrant@precise64:~$ ls -ld /home/vagrant/.matplotlib/
drwxrwxrwx 1 vagrant vagrant 4096 Sep 26 18:07 /home/vagrant/.matplotlib/

更新:

好像是因为

OSError: [Errno 26] Text file busy: '/home/vagrant/.matplotlib/tmp3ciLMo'

我怀疑这与 vagrant 将我的主文件夹安装为同步文件夹有关

【问题讨论】:

  • 文件系统是否读/写?
  • 命令行中的touch /home/vagrant/test 有什么作用?
  • 是的,都是读/写。触摸 /home/vagrant/test >> -rwxrwxrwx 1 vagrant vagrant 0 Sep 26 22:21 /home/vagrant/test
  • 您的同步文件夹设置是什么样的?通过 vboxsf 处理大量文件/目录会导致性能和各种问题。
  • 有人设法解决了这个问题吗?

标签: python matplotlib virtualbox vagrant


【解决方案1】:

这可能是 VirtualBox 在同步文件夹中具有低级文件系统操作(如 rmdir)的长期问题。这是在 Vagrant 提交的原始问题:

https://github.com/hashicorp/vagrant/issues/2282

具有相同错误模式的最新 VirtualBox 问题:

我仍然可以使用当前的 VirtualBox 6.0 和 6.1 版本及其相应的 Guest Additions 版本来重现它。

我无法在任何 VirtualBox 版本(包括 6.0 和 6.1)上重现 Guest Additions 5.x 的问题。所以这可能是一种解决方法。

另一种解决方法是使用另一个synced folder mechanism

【讨论】:

    【解决方案2】:

    当我执行vagrant provision 时,我遇到了类似的错误。当您尝试以正在执行的写入模式打开可执行文件时,会出现错误 26。使用lsof &lt;file&gt; 查看执行文件的进程。终止进程后,您可以避免此错误。

    参考资料:

    http://man7.org/linux/man-pages/man3/errno.3.htm

    https://stackoverflow.com/a/15514388/547578

    【讨论】:

      【解决方案3】:

      运行lsof /home/vagrant/.matplotlib/tmp3ciLMofuser /home/vagrant/.matplotlib/tmp3ciLMo 以检查它使用文件的哪个进程导致它忙。

      然后杀死进程释放文件。

      【讨论】:

        猜你喜欢
        • 2021-03-29
        • 1970-01-01
        • 1970-01-01
        • 2014-11-17
        • 2015-02-06
        • 1970-01-01
        • 2011-09-14
        • 2016-10-07
        • 1970-01-01
        相关资源
        最近更新 更多