问题描述
原标题:MPLCONFIGDIR .matplotlib not writeable on matplotlib import
Originally titled: MPLCONFIGDIR .matplotlib not writeable on matplotlib import
我正在运行pylearn2的教程,并且在导入 matplotlib.pyplot
时遇到一些错误.一些可能不必要的信息是我在 Vagrant 生成的 VirtualBox 中运行它.我已经看到几个类似的错误都涉及 django,但我不是要尝试虚拟主机,也不是空间不足.我已经尝试过以root身份运行python,因为那样是不安全的,但是它仍然无法正常工作.我也尝试将MPLCONFIGDIR变量设置为相同的错误.请让我知道我是否可以提供更多信息.谢谢.
I am running the tutorial for pylearn2 and I'm getting some errors when it imports matplotlib.pyplot
. Some information that is probably unnecessary is that I'm running it in a VirtualBox generated by Vagrant. I've seen a couple of similar errors all referring to django, but I'm not trying to webhost, nor am I out of space. I've tried running python as root, as unsafe as that is, but it still didn't work. I have also tried setting my MPLCONFIGDIR variable with the same error. Please let me know if there is any more information I can include. Thanks.
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 是我的主目录,所以它是可写的,但对于相关...
/home/vagrant is my home directory so it is writable, but for the concerned...
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 有关系
which I suspect has something to do with vagrant mounting my home folder as a synced_folder
推荐答案
这可能是VirtualBox长期存在的问题,它在同步文件夹中具有低级文件系统操作(如rmdir).这是在Vagrant提出的原始问题:
This could be a long-standing issue of VirtualBox with low-level filesystem operations (like rmdir) in synced folders. This was an original issue filed at Vagrant:
https://github.com/hashicorp/vagrant/issues/2282
具有相同错误模式的最新 VirtualBox 问题:
The most up-to-date VirtualBox issues with the same error pattern:
我仍然可以使用当前的VirtualBox 6.0和6.1版本及其相应的Guest Additions版本来重现它.
I can still reproduce it with the current VirtualBox 6.0 and 6.1 versions and their appropriate Guest Additions versions.
我无法在任何VirtualBox版本(包括6.0和6.1)上重现Guest Additions 5.x的问题.因此,这可能是一种解决方法.
I can't reproduce the problem with Guest Additions 5.x on any VirtualBox version (including 6.0 and 6.1). So this might be a workaround.
另一种解决方法是使用另一种同步文件夹机制.
Another workaround would be to use another synced folder mechanism.
这篇关于OSError:[Errno 26]文本文件忙于带有synced_folder的流浪汉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!