Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeprecationWarning: datetime.datetime.utcnow() is deprecated #1012

Closed
yuvadm opened this issue Oct 27, 2024 · 2 comments
Closed

DeprecationWarning: datetime.datetime.utcnow() is deprecated #1012

yuvadm opened this issue Oct 27, 2024 · 2 comments
Labels
platform bug Bugs in operating systems, Python installations, or third-party packages

Comments

@yuvadm
Copy link

yuvadm commented Oct 27, 2024

Skyfield is using utcnow() which is being deprecated:

return self.from_datetime(self._utcnow().replace(tzinfo=utc))

This results in warnings being thrown:

.venv/lib/python3.12/site-packages/skyfield/timelib.py:134: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    return self.from_datetime(self._utcnow().replace(tzinfo=utc))
@yuvadm yuvadm changed the title utcnow() is being deprecated DeprecationWarning: datetime.datetime.utcnow() is deprecated Oct 27, 2024
ruitcatarino pushed a commit to ruitcatarino/python-skyfield that referenced this issue Oct 29, 2024
@brandon-rhodes brandon-rhodes added the platform bug Bugs in operating systems, Python installations, or third-party packages label Jan 5, 2025
@ursomniac
Copy link

I ran into this on "my side" using SkyField:
the fix is to replace:
datetime.datetime.utcnow()
with: datetime.datetime.now(datetime.timezone.utc)

@brandon-rhodes
Copy link
Member

I have committed a fix and it should be in the next Skyfield release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform bug Bugs in operating systems, Python installations, or third-party packages
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants