<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ImportError: PyCapsule_Import could not import module &amp;quot;datetime&amp;quot; - for Pro3.1.3&amp;gt;conda arcpy clone in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/importerror-pycapsule-import-could-not-import/m-p/1342157#M69049</link>
    <description>&lt;P&gt;Did you try installing the DateTime package directly into your site-packages in your virtual environment?&lt;/P&gt;</description>
    <pubDate>Thu, 26 Oct 2023 17:08:41 GMT</pubDate>
    <dc:creator>AngelaSchirck</dc:creator>
    <dc:date>2023-10-26T17:08:41Z</dc:date>
    <item>
      <title>ImportError: PyCapsule_Import could not import module "datetime" - for Pro3.1.3&gt;conda arcpy clone</title>
      <link>https://community.esri.com/t5/python-questions/importerror-pycapsule-import-could-not-import/m-p/1340909#M69021</link>
      <description>&lt;P&gt;Hello - After running a conda update arcgis in my Pro3.1.3 envrionment 2 days ago (10/22/2023), I am suddenly getting an import error for datetime import.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In most cases, I'm just using datetime to set up datetime differences to get a script runtime email from the Python IDLE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;##ArcGIS api for starting and stopping services.  Run in 3.9.16
#Import system modules
import sys, string, os, arcpy, time, smtplib
from datetime import date, timedelta
from arcpy import env
from arcgis.gis import GIS

# Local variables...
message = ""
current_time = time.asctime()
todaysDate = date.today()
priorYear = str(todaysDate - timedelta(days=547)) #547
starting_time = time.time()

try:
gis = GIS("https://sub.domian.net/portal", "myuser_", "mypwd")

gis_servers = gis.admin.servers.list()
print(gis_servers)
#message = message + "\n" + str(gis_servers)

agsfed = gis_servers[1]
print(agsfed)
#message = message + "\n" + str(agsfed)

scpaServicesList = agsfed.services.list(folder='ScpaServices')
for scpaService in scpaServicesList:
print(scpaService.properties.serviceName)
message = message + "\n" + str(scpaService.properties.serviceName)
scpaService.start()
print(scpaService.status)
message = message + "\n" + str(scpaService.status)

except Exception:
# If an error occurred, print line number and error message
import traceback, sys
tb = sys.exc_info()[2]
e = sys.exc_info()[1]
#print(e.args[0])
#print "Line %i" % tb.tb_lineno
message = message + "\n" + "Line %i" % tb.tb_lineno
message = message + "\n" + e.message

# Below is to send email message.
fromAddr = "dcoley@domain.net"
toAddr = ["dcoley@scgov.net"]

subject = "SCRIPT: Start Collector Services"
finish_time = time.asctime()
fininshing_time = time.time()

elapsed_time = fininshing_time - starting_time
total_time = str(timedelta(seconds=elapsed_time))

msgBody = current_time + "\n\n" + message + "\n\n" + "Thank you." + "\n\n" + finish_time + "\n\n" + "Total time elasped is: " + total_time

msg = 'From: {}\nTo: {}\nSubject: {}\n\n{}'.format(fromAddr, toAddr, subject, msgBody)

server = smtplib.SMTP("smtp.domain.net")
server.set_debuglevel(1)
server.sendmail(fromAddr,toAddr,msg)
server.quit()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then I get the&amp;nbsp;&lt;/P&gt;&lt;P&gt;ImportError: PyCapsule_Import could not import module "datetime".&amp;nbsp;&lt;/P&gt;&lt;P&gt;So really just seems to be a bad conda udpdate. When I reverted back to the Default environment, I do not&amp;nbsp; get the import error.&lt;/P&gt;&lt;P&gt;Is anyone else experiencing this?&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2023 14:30:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importerror-pycapsule-import-could-not-import/m-p/1340909#M69021</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2023-10-24T14:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: ImportError: PyCapsule_Import could not import module "datetime" - for Pro3.1.3&gt;conda arcpy clone</title>
      <link>https://community.esri.com/t5/python-questions/importerror-pycapsule-import-could-not-import/m-p/1342157#M69049</link>
      <description>&lt;P&gt;Did you try installing the DateTime package directly into your site-packages in your virtual environment?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 17:08:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importerror-pycapsule-import-could-not-import/m-p/1342157#M69049</guid>
      <dc:creator>AngelaSchirck</dc:creator>
      <dc:date>2023-10-26T17:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: ImportError: PyCapsule_Import could not import module "datetime" - for Pro3.1.3&gt;conda arcpy clone</title>
      <link>https://community.esri.com/t5/python-questions/importerror-pycapsule-import-could-not-import/m-p/1342927#M69064</link>
      <description>&lt;P&gt;I did not but thanks the suggestion.&amp;nbsp; I could try, but since the upgrade for the arcgis package at Pro 3.1.3 is from&amp;nbsp;2.1.0.2 to 2.1.0.3 - and the arcgis api is at 2.2, I think I'll wait for the next Pro release as I'm not doing anything that requires any of the other packages to be upgraded at this time.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2023 20:26:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/importerror-pycapsule-import-could-not-import/m-p/1342927#M69064</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2023-10-27T20:26:19Z</dc:date>
    </item>
  </channel>
</rss>

