mikejc
Posts: 2
Joined: Wed Oct 11, 2017 11:00 am

Problem with datetime

Wed Oct 11, 2017 11:11 am

I have a PI camera that took images OK a year ago. Now, however, the camera.capture call fails in the encoders.py library. The traceback is:

File "/usr/lib/python3/dist-packages/picamera/encoders.py", line 112, in start
timestamp = datetime.datetime.now()
AttributeError: 'module' object has no attribute 'datetime'

I get this problem even with the very basic program in "getting started with pi camera" web site. I have updated Raspian and am running Python 3.4.2.

If I try a simple program:
import datetime
timestamp = datetime.datetime.now()

I get the same error.

Any ideas

B.Goode
Posts: 4620
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Problem with datetime

Wed Oct 11, 2017 11:16 am

Do you have a file in your working directory named datetime.py?

That would confuse the Python interpreter.

mikejc
Posts: 2
Joined: Wed Oct 11, 2017 11:00 am

Re: Problem with datetime

Sun Oct 15, 2017 6:57 pm

Thanks, that sorted it. Silly mistake!

Return to “Python”

Who is online

Users browsing this forum: No registered users and 23 guests