简体   繁体   中英

OSError: [Errno 26] Text file busy on vagrant with synced_folder

Originally titled: MPLCONFIGDIR .matplotlib not writeable on matplotlib import

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 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/

UPDATE:

it seems to be caused by

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

which I suspect has something to do with vagrant mounting my home folder as a synced_folder

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

The most up-to-date VirtualBox issues with the same error pattern:

I can still reproduce it with the current VirtualBox 6.0 and 6.1 versions and their appropriate Guest Additions versions.

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 .

I have the similar error when I do vagrant provision . Error 26 occurs when you try to open an executable file in writing mode which is being executed. Use lsof <file> to see the process executing the file. You can avoid this error after you terminate the process.

References:

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

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

Run lsof /home/vagrant/.matplotlib/tmp3ciLMo or fuser /home/vagrant/.matplotlib/tmp3ciLMo to check what process it using the file that cause it busy.

Then kill the process to release the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM