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

Issues with datetime imports; arcgis python API is overwriting the import causing a runtime exception #1765

Open
pfoppe opened this issue Feb 27, 2024 · 1 comment
Assignees
Labels

Comments

@pfoppe
Copy link

pfoppe commented Feb 27, 2024

Describe the bug
"datetime" module is imported when creating a "GIS" object. This datetime import is overwriting the main code datetime import causing errors such as "AttributeError: module 'datetime' has no attribute 'strftime'"

To Reproduce
Steps to reproduce the behavior:

Run this code first to show datetime behavior without the arcgis python API:

from datetime import datetime
dt=datetime.strftime(datetime.now(),"%Y%m%d_%H%M%S")
print(dt)

The output will be a datetime stamp in the specified format

Run this code second to show datetime behavior is corrupted when using the arcgis python API:

from datetime import datetime
from arcgis import GIS
mygis=GIS("pro")
dt=datetime.strftime(datetime.now(),"%Y%m%d_%H%M%S")
print(dt)

error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'datetime' has no attribute 'strftime'

Screenshots
N/A

Expected behavior
When creating an arcgis python API object, it should not corrupt my previous imports

Platform (please complete the following information):

  • OS: Windows 10
  • Browser: N/A
  • Python API Version:2.1.0.2

Additional context

It appears the 'datetime' module is imported after creation of the "GIS" object.

Quick fix around this issue...

#Fix Esri bug
try:
    dt=datetime.strftime(datetime.now(),"%Y%m%d_%H%M%S")
except:
    dt=datetime.datetime.strftime(datetime.datetime.now(),"%Y%m%d_%H%M%S")
@pfoppe pfoppe added the bug label Feb 27, 2024
@nanaeaubry nanaeaubry self-assigned this Feb 27, 2024
@nanaeaubry
Copy link
Contributor

@pfoppe I can confirm this is occurring as well when login is "pro"
We will look into this.

Workaround for now can be your try/except or to import datetime after you login.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants