I'm trying to use my PiCamera, and while doing that (writing some python code to use it), I keep getting this error message:

Traceback (most recent call last):
  File "/home/pi/Desktop/picamera.py", line 1, in <module>
    from picamera import PiCamera
  File "/home/pi/Desktop/picamera.py", line 1, in <module>
    from picamera import PiCamera
ImportError: cannot import name 'PiCamera'

The camera is working because I tested it in the command line: raspistill -o image.png

I am using Python 3.

  • try this import picamera pay attention to the capitalization – Steve Robillard Apr 14 '17 at 19:26
  • @SteveRobillard I did from picamera import PiCamera Also I tried just to import picamera and then do: camera = picamera.PiCamera() But in both situations I receive the error from above. – Florin Apr 14 '17 at 19:37
  • try this pip3 install PiCamera then retry the import – Steve Robillard Apr 14 '17 at 19:47
  • @SteveRobillard : I've tried and what I get is: Requirement already satisfied – Florin Apr 14 '17 at 19:51
  • how did you fix the error ? I am having the same problem. If you could explain it would be nice of you – mnabeel Nov 25 '17 at 9:04

The problem is that I used python 3.4, and while compiling the code in terminal (python script.py) it was compiled in python 2.7. I have both versions installed.


According to the Picamera docs:

When trying out these scripts do not name your file picamera.py. Naming scripts after existing Python modules will cause errors when you try and import those modules (because Python checks the current directory before checking other paths).

You can't name your script picamera.py, otherwise, Python will think that's the module.

So you will have to rename your script to something else.

I like to call it picam.py

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