Select to view content in your preferred language

ImportError: PyCapsule_Import could not import module "datetime"

2614
15
Jump to solution
12-04-2023 11:49 AM
Rob24
by
Emerging Contributor

Hello, I have been running some scripts for a while without issue.  Even after upgrading to ArcGis 3.1.1

Now, started receiving this error at random times in the code:

(this error shows it occurred in CopyFeatures, sometimes it happens during other functions)

Fatal Python error: InitDatetime: Could not import datetime C API
Python runtime state: initialized
ImportError: PyCapsule_Import could not import module "datetime"

Current thread 0x000025ac (most recent call first):
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512 in <lambda>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4690 in CopyFeatures

installed:
Conda version is 4.1.4
Base Python on machine is 3.11
PyCharm 2021.1.3 (Community Edition)
Build #PC-211.7628.24, built on June 29, 2021
Runtime version: 11.0.11+9-b1341.60 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16

 

Tried the following:

1. uninstalled:

   ArcGIS Pro
   Pycharm
   Python

2. removed any lingering folders for:

   ArcGIS Pro
   pip cache

3. re-installed all 3 (from 1)


Been working with ArcGis for about a year now, still learning.   Any guidance on this would be appreciated.

0 Kudos
15 Replies
DanPatterson
MVP Esteemed Contributor

Tech Support would be your best option if you removed all python, pycharm and Pro installations.

There is little use in installing 3.1.1 if you are having problems

Pro 3.2 uses 3.9.18

Good luck


... sort of retired...
0 Kudos
Rob24
by
Emerging Contributor

Hi Dan, that is my next step, appreciate your time!

0 Kudos
Luiz_RobertoArueira_da_Silva
Occasional Contributor

Good morning!
I have a similar problem!
I created a script from the export of an ArcGis Pro model, using Python from ArcGis Pro 3.2 (Python 3.9.18 [MSC v.1931 64 bit (AMD64)] on win32), recently installed.
When executing the script, the message appears when executing the command: arcpy.conversion.ExportFeatures
ImportError: PyCapsule_Import could not import module "datetime"

If anyone has an idea on how to solve it....
Thanks!

0 Kudos
DanPatterson
MVP Esteemed Contributor

copy the script here so people can see what might be causing the issue

Code formatting ... the Community Version - Esri Community


... sort of retired...
0 Kudos
Luiz_RobertoArueira_da_Silva
Occasional Contributor

Sorry, I don't have permission to share the code.

A part of the command that generates the error:

print ("select by location camada realizado")

# Process: Export Features (Export Features) (conversion)
Incidentes_filtrado = "in_memory\\Incidentes_filtrado"
arcpy.conversion.ExportFeatures(in_features=incidentes_Layer1, out_features=Incidentes_filtrado, field_mapping="uuid .....

login efetuado
select by attribute camada do realizado
select by location camada realizado
ImportError: PyCapsule_Import could not import module "datetime"

Thanks foo your time!

0 Kudos
DanPatterson
MVP Esteemed Contributor

You will have to contact tech support.  There isn't enough information to decipher a possible cause with what is given


... sort of retired...
0 Kudos