8

For starting the camera I am doing

>>> import picamera 
>>> camera = picamera.PiCamera()
mmal: mmal_vc_component_enable: failed to enable compononent : ENOSPC
Traceback (most recent call last):
  File "<stdin>", line, in <module>
  ...
  ...
picamera.exc.PiCameraMMALError: Camera component couldn't be enabled: Out of resources (other than memory)

I checked lot of answers which told to update the package and I did that but nothing seems to help. IS my camera gone or is there some solution?

14 Answers 14

6

As an addition to the other answers, I just want to mention that the cause for this error could also be that another process is currently using the camera.

  • 1
    I think you could be right. I started to get this error after interrupting a camera script that wasn't responding (using CTRL-C). Camera was working fine prior to this. So how do I release/reset the camera so it works again? – Bill Jul 2 '16 at 4:19
4

The Raspberry Pi Camera Module uses the onboard GPU and its memory. Since your error message mentions being out of resources, consider adding at least (and possibly more than) the recommended minimum of 128MB to the GPU's allotment.

To change it:

sudo raspi-config

select: Advanced options -> Memory split -> and set at least 128MB

Some users report this message disappearing after changing the GPU memory allotment to 256MB from 128MB.

  • This was the case for me. After an update, 128MB were not enough anymore, I had to set it to 256MB. – Nicolas BADIA Jun 6 '18 at 13:14
3

Follow this order of commands:

  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo rpi-update

The last one is very important if you bought your Raspberry a long time ago, AND if you want some new features.

3

For anyone else with this problem... if the light is on at boot then you really might have the wrong ribbon cable port! The cable will fit nicely into the LCD port and the light will turn on and everything. But you will get the error saying to enable the device.

Werner pointed this out: https://blog.adafruit.com/wp-content/uploads/2014/01/1646pi_LRG-600x461.jpg

2

The solution is to ensure that the line, camera = PiCamera() is outside of any loop or function.

If the line camera = PiCamera() is called every time your function runs then the Camera runs out of memory.

camera = PiCamera()

def Take_an_Image():

    camera.resolution = (1024, 768)
    camera.start_preview()
    camera.capture("Test")
  • It doesn't appear that this specific error was due to running out of memory (the error was "Camera component couldn't be enabled: Out of resources (other than memory)"), and the OP didn't declare their camera in a loop, but this is good advice if someone does run out of memory. – Aurora0001 Jan 7 '18 at 12:12
2

I ran into this same problem with the Rasp Pi 3. I started a python script that would take 1 image per second for a minute. I hit ctrl-z to interrupt script execution about halfway through. When I tried to run the script again, I got this error, although it appeared that no other scripts were using the camera.

The fix: Enter "ps -a" to list all of the currently running processes. Look for one that says "python" or "python3" in the output, like this:
PID TTY TIME CMD 1218 tty1 00:00:00 bash 2203 pts/0 00:00:00 python 8960 pts/1 00:00:00 ps

Use the command "kill -KILL [PID#]" to stop the python process. For this case, the command was "kill -KILL 2203".

After doing this, use "ps -a" again to make sure the python process is not listed.

This cleared up the problem for me, and I was able to run my script again without any issues.

Hope this helps.

1

In addition to alcor's answer, make sure you run raspi-config, and choose option 5 after you boot up, to enable camera support.

I think you might need to use sudo

1

So it turns out that Camera port of my Raspberry Pi had some problem. Replaced the Pi, camera is working smoothly.

1

I ran into same issue. I realized that since I was broadcasting video via httpd, I could not make use of the images via Python. I had to choose to either let the Python script access the images or let the Apache server make video available via browser. Only one process can access the camera at a time.

1

I had this ressource issue, it turned out the fonction camera.capture(filename) was the problem, because the file already existed.

1

In my code there was a silly bug that gave raise to this error: I opened the camera once, but intentionally tried to open it again when the user clicks a hardware button. Closing the camera before the second call to PiCamera() resolved the problem.

0

You will get this error if your button is not properly connected. The Pi will think the button is pressed and continually try to take photos, hence you will be out of resources!

Make sure your button is plugged into the correct GPIO pin and then continue to other methods of debugging.

0

Just my penny worth.. I wrote a small program that takes a sequence of pics. It worked fine in IDLE, but from command line came up with exact same error being out of resources. The problem was fixed by adding camera.close() after except KeyboardInterrupt:, ie Ctrl+C (in the python shell). for when you need to break out of a loop.

  • Thanks for your answer. Because it's your first answer, I've been prompted by the system to review it, and make any comments that might help you improve it. I'm struggling to understand what your proposed answer is. Please try to be more specific; e.g. provide some code that you feel will resolve the issue. I'd also recommend you read "How to write a good answer". Please consider these suggestions, and edit your answer accordingly. – Seamus Sep 16 '18 at 18:13
0

For my case, having the same error, replacing the camera module fixed it. I was able to reliably reproduce the error by switching back and forth between good and bad camera modules. My code did not suffer from the problems others pointed out. So it seems hardware problems can cause this exception too.

The exception was:

picamera.exc.picamerammalerror: failed to enable connection: out of resources

Picamera version is 1.13 and the camera module is v2.1

protected by goldilocks Oct 31 '18 at 20:37

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.