Errno 24 Too many open files when using Psychopy - psychopy

I have 40 videos that I would like to present in a random loop 15 times. Even though the experiment runs all the way through my .csv file output does not save and I get an error saying too many files are open
If I change the number of repetitions to 5 it works and saves all the data.
Anything above 5 has the error [Errno 24] Too many open files and saves only the .log file.
Is there piece of code I can add in my .py to close each file after its shown? Or is it an Operating System problem? I use Windows 7. Any ideas are greatly appreciated.
Below the entire output message.
################## Running: F:\Movies\Block 1_lastrun.py ##################
Traceback (most recent call last):
File “U:\Final draft\Block 1_lastrun.py”, line 189, in
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\movie3.py”, line 134, in init
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\visual\movie3.py”, line 180, in loadMovie
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\VideoFileClip.py”, line 81, in init
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\ffmpeg_reader.py”, line 32, in init
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\moviepy\video\io\ffmpeg_reader.py”, line 256, in ffmpeg_parse_infos
File “C:\Program Files (x86)\PsychoPy2\lib\subprocess.py”, line 745, in init
OSError: [Errno 24] Too many open files
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\atexit.py”, line 24, in _run_exitfuncs
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\data\experiment.py”, line 366, in close
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\data\experiment.py”, line 351, in saveAsPickle
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\tools\filetools.py”, line 149, in openOutputFile
File “C:\Program Files (x86)\PsychoPy2\lib\codecs.py”, line 896, in open
IOError: [Errno 24] Too many open files: u’U:\Final draft\data/_BM-Stimulation_2018_Jun_13_1535.psydat’
Error in sys.exitfunc:
Traceback (most recent call last):
File “C:\Program Files (x86)\PsychoPy2\lib\atexit.py”, line 24, in _run_exitfuncs
func(*targs, **kargs)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\data\experiment.py”, line 366, in close
self.saveAsPickle(self.dataFileName)
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\data\experiment.py”, line 351, in saveAsPickle
fileCollisionMethod=fileCollisionMethod) as f:
File “C:\Program Files (x86)\PsychoPy2\lib\site-packages\psychopy\tools \filetools.py”, line 149, in openOutputFile
f = codecs.open(fileName, mode=mode, encoding=encoding)
File “C:\Program Files (x86)\PsychoPy2\lib\codecs.py”, line 896, in open
file = builtin.open(filename, mode, buffering)
IOError: [Errno 24] Too many open files: u’F:\Movies\data/_BM- Stimulation_2018_Jun_26_1533.psydat’

Related

Object detection on raspberry pi

I am trying to run the following project:
https://github.com/krishrustagi/Accident-Detection-System
I do not know what I am doing wrong.This project seems really interesting and I really want to learn more about it.
How do I get the github repository above to work.
Maybe a simple fix?
Here is the error code I get when executing the camera.py command:
(env) pi#raspberrypi:~/Project/Accident-Detection-System $ python3 camera.py Traceback
(most recent call last):
File "/home/pi/Project/Accident-Detection-System/camera.py", line 6, in <module>
model = AccidentDetectionModel("model.json", 'model_weights.h5')
File "/home/pi/Project/Accident-Detection-System/detection.py", line 15, in __init__
self.loaded_model.load_weights(model_weights_file)
File "/home/pi/Project/Accident-Detection-System/env/lib/python3.9/site-
packages/keras/utils/traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/pi/Project/Accident-Detection-System/env/lib/python3.9/site-
packages/h5py/_hl/files.py", line 533, in __init__
fid = make_fid(name, mode, userblock_size, fapl, fcpl, swmr=swmr)
File "/home/pi/Project/Accident-Detection-System/env/lib/python3.9/site-
packages/h5py/_hl/files.py", line 226, in make_fid
fid = h5f.open(name, flags, fapl=fapl)
File "h5py/_objects.pyx", line 54, in h5py._objects.with_phil.wrapper
File "h5py/_objects.pyx", line 55, in h5py._objects.with_phil.wrapper
File "h5py/h5f.pyx", line 106, in h5py.h5f.open
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name =
'model_weights.h5', errno = 2, error message = 'No such file or directory', flags = 0, o_flags
= 0)
The error trace is telling you that the file model_weights.h5 does not exist anywhere in the project root directory.
After looking at the GitHub repo, it seems that model.json exists but model_weights.h5 does not, while both are supplied as arguments in camera.py Line 6:
model = AccidentDetectionModel("model.json", 'model_weights.h5')
The README mentioned this in Section 5:
accident-classification.ipynb: This is a jupyter notebook that generates a model to classify the above data. This file generates two important files model.json and model_weights.h5.
Hence you should run accident-classification.ipynb first before running camera.py.

LetsEncrypt Certbot-Auto freezes when trying to run any command on Apache

I am trying to get LetsEncrypt SSL certificates installed on a Centos 6 server using Cerbot-Auto, however no matter what I try, it just hangs on:
Apache version is 2.2.15
Command
./certbot-auto -v
When I press CTRL + C to exit the program, it takes about 15 seconds and then exits with a stack trace:
Exiting abnormally:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 9, in <module>
load_entry_point('letsencrypt==0.7.0', 'console_scripts', 'letsencrypt')()
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/main.py", line 1240, in main
return config.func(config, plugins)
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/main.py", line 981, in run
installer, authenticator = plug_sel.choose_configurator_plugins(config, plugins, "run")
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/plugins/selection.py", line 189, in choose_configurator_plugins
authenticator = installer = pick_configurator(config, req_inst, plugins)
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/plugins/selection.py", line 25, in pick_configurator
(interfaces.IAuthenticator, interfaces.IInstaller))
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/plugins/selection.py", line 77, in pick_plugin
verified.prepare()
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/plugins/disco.py", line 248, in prepare
return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/plugins/disco.py", line 248, in <listcomp>
return [plugin_ep.prepare() for plugin_ep in six.itervalues(self._plugins)]
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot/plugins/disco.py", line 130, in prepare
self._initialized.prepare()
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot_apache/configurator.py", line 225, in prepare
self.parser = self.get_parser()
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot_apache/override_centos.py", line 39, in get_parser
self.version, configurator=self)
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot_apache/override_centos.py", line 47, in __init__
super(CentOSParser, self).__init__(*args, **kwargs)
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot_apache/parser.py", line 74, in __init__
if self.find_dir("Define", exclude=False):
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/certbot_apache/parser.py", line 401, in find_dir
"%s//*[self::directive=~regexp('%s')]" % (start, regex))
File "/opt/eff.org/certbot/venv/lib64/python3.4/site-packages/augeas.py", line 413, in match
ctypes.byref(array))
KeyboardInterrupt
Please see the logfiles in /var/log/letsencrypt for more details.
I thought it may be a python version issue but when checked, the server is running Python 2.6.6, which, according to the Certbot System Requirements is acceptable.
Letsencrypt.log
When I checked the log, it is exactly the same stacktrace as was reported by the script previously.
Any ideas?

Renaming the model Directory in Tensorflow

I renamed the model dir from /home/abcd/andrew_model_jul25_tif/ which contained model and summary directories to /home/abcd/andrew_model_sep22/ which contained the same two folders. When I ran the python script it gave me the following error:
Traceback (most recent call last):
File "eval_on_full_image.py", line 127, in <module>
tf.app.run()
File "/home/abcd/virtualenvs/project/local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "eval_on_full_image.py", line 119, in main
do_eval_on_whole(model_dir, file, file[a:], output_dir)
File "eval_on_full_image.py", line 51, in do_eval_on_whole
saver.restore(sess,tf.train.latest_checkpoint(model_dir))
File "/home/abcd/virtualenvs/project/local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1602, in latest_checkpoint
if file_io.get_matching_files(v2_path) or file_io.get_matching_files(
File "/home/abcd/virtualenvs/project/local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 334, in get_matching_files
compat.as_bytes(single_filename), status)
File "/usr/lib/python2.7/contextlib.py", line 24, in __exit__
self.gen.next()
File "/home/abcd/virtualenvs/project/local/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.NotFoundError: /home/abcd/andrew_model_jul25_tif/model
When I changed the folder's name back to andrew_model_jul25 the script worked. Can changing the folder's name have such an effect?
I'm using the 1.1.0 version of tf, and running it on a GPU.
The problem arises here:
saver.restore(sess,tf.train.latest_checkpoint(model_dir))
Try updating the name of your model_dir variable

Redownloaded custom built tensorflow wheel wont install

I've built Tensorflow with custom SIMD extensions and created a wheel for it. If I simply do pip install /tmp/tensorflow_pkg/tensorflow-1.0.0-cp27-cp27mu-linux_x86_64.wh on the box that I built it on, that works. However if I upload the whl file to cloud storage, and do pip install https://storage.cloud.google.com/path/to/tensorflow-1.0.0-cp27-cp27mu-linux_x86_64.whl I get this error:
Collecting tensorflow==1.0.0 from https://storage.cloud.google.com/path/to/tensorflow-1.0.0-cp27-cp27mu-linux_x86_64.whl
Downloading https://storage.cloud.google.com/path/to/tensorflow-1.0.0-cp27-cp27mu-linux_x86_64.whl
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 821, in unpack_url
hashes=hashes
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 663, in unpack_http_url
unpack_file(from_path, location, content_type, link)
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 599, in unpack_file
flatten=not filename.endswith('.whl')
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 484, in unzip_file
zip = zipfile.ZipFile(zipfp, allowZip64=True)
File "/usr/local/lib/python2.7/zipfile.py", line 770, in __init__
self._RealGetContents()
File "/usr/local/lib/python2.7/zipfile.py", line 811, in _RealGetContents
raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file
Do I need to configure my build differently somehow?
(capturing the solution as an answer)
The URL used for the download is not correct. The base url needed to be storage.googleapis.com

Using redis with bokeh-server. Permission denied: '/bokehpids.json'

I'm trying to run bokeh-server with supervisor with redis as a backend and I get this error message on startup:
Traceback (most recent call last):
File "/usr/share/nginx/test-status/flask/bin/bokeh-server", line 7, in <module>
bokeh.server.run()
File "/usr/share/nginx/test-status/flask/lib/python2.7/site-packages/bokeh/server/__init__.py", line 175, in run
start_server(args)
File "/usr/share/nginx/test-status/flask/lib/python2.7/site-packages/bokeh/server/__init__.py", line 179, in start_server
start.start_simple_server(args)
File "/usr/share/nginx/test-status/flask/lib/python2.7/site-packages/bokeh/server/start.py", line 54, in start_simple_server
start_redis()
File "/usr/share/nginx/test-status/flask/lib/python2.7/site-packages/bokeh/server/start.py", line 40, in start_redis
save=redis_save)
File "/usr/share/nginx/test-status/flask/lib/python2.7/site-packages/bokeh/server/services.py", line 81, in start_redis
stdin=subprocess.PIPE
File "/usr/share/nginx/test-status/flask/lib/python2.7/site-packages/bokeh/server/services.py", line 32, in __init__
self.add_to_pidfile()
File "/usr/share/nginx/test-status/flask/lib/python2.7/site-packages/bokeh/server/services.py", line 46, in add_to_pidfile
with open(self.pidfilename, "w+") as f:
IOError: [Errno 13] Permission denied: '/bokehpids.json'
Note that I can run the server with supervisor if I use memory as the backend, and I can run bokeh-server manually with redis as a backend just fine. Does anyone know where the permissions I should change lie?
Turns out it was trying to access the pidfile in the root directory...
I solved this by changing the directory in the supervisor config file:
[program:bokeh]
...
directory=/usr/share/nginx/test-status
...