python - 操作系统错误: [Errno 26] Text file busy on vagrant with synced_folder

标签 python matplotlib virtualbox vagrant

原标题为:MPLCONFIGDIR .matplotlib 在 matplotlib 导入时不可写入

我正在运行 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 将我的主文件夹安装为synced_folder有关

最佳答案

这可能是 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 .

关于python - 操作系统错误: [Errno 26] Text file busy on vagrant with synced_folder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19036016/

相关文章:

python - 用 Python 关闭大括号

python - 嵌套序列化器中的 Django Rest Framework 自定义 URL

python - 使用 PyInstaller 时没有命名模块

windows - 在 Windows 上安装 Docker 后无法启动我的虚拟 Box 机

c - 读写 mmap 的参数无效?

python - 如何替换Python中的多个if循环?

Python - 如何获取 Ubuntu 上聚焦窗口的进程名称?(不是窗口标题)

python - 在 Python 的 matplotlib 中绘制球体表面的点

python - matplotlib 中绘图点的标签

.net - VirtualBox 上的共享文件夹未使用 Visual Studio 2015(网站项目)打开