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.
Solved! Go to Solution.
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
arctoolbox functions like CopyFeatures would be expecting arcpy based on python 3.9.18, your base
...Base Python on machine is 3.11...
if you are working in different python versions, are you switching back to an arcpy/arcgis happy environment first?
Hi Dan, Thank you for the response,
I currently only work with the ArcGIS Python so the interpreter is set to Conda environment pointing to the arcgispro-py3 env.
.Base Python on machine is 3.11...
came from your error message, do you have other python versions installed?
Hi Dan,
I only have python 3.11
you have arcgis pro installed, hence you should have python 3.9,18 installed as well
"C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 4690 in CopyFeatures
arcpy is built against 3.9.18
Dan, I can uninstall python 3.11 and go grab 3.9.18 .
I'm wondering if this explains why sometimes it would actually run fine and other times just error out (erratic behavior) .
That would be useful and I would recommend a complete reinstall of Pro if you use it mostly
Don't be worried about the title, the procedure is what is important
Thank you Dan!, I will try this route and report back.
Update: still having the same issue. I installed ArcGIS 3.1.1 (without installing Python separately). and the error keeps coming back to CopyFeatures.
in the pycharm terminal:
python --version
Python 3.9.16
I know you mentioned arcpy was built against 3.9.18 so I don't know if this is now the issue.
still do not understand why these same scripts where working for months and without changes or updates and started getting this error.
either way, thank you for the help @DanPatterson I appreciate it!