2

My python kernel and ArcGIS both crash when I try to export a spatially enabled DataFrame to a featurelayer or featureclass in one of my virtual environments.

In addition to the python and ArcGIS crash messages, I also get the error:

ImportError: PyCapsule_Import could not import module "datetime"

While I've seen some posts on GitHub about that error message, I haven't seen anything that helps with the SEDF export.

However, trying the same code in a different virtual environment does work, so it seems to be something to do with my conda environment.

Here's a reprex:

import pandas as pd
from arcgis.gis import GIS
gis = GIS(url = url, username = username, password = password)
from arcgis.features import GeoAccessor

df = pd.DataFrame({'a' : [1], 
                   'longitude' : 143.01363,
                   'latitude' : 44.77826})

sdf = pd.DataFrame.spatial.from_xy(
    df=df,
    x_column='longitude',
    y_column='latitude',
    sr=4326
)
sdf.spatial.to_featurelayer('test', gis = gis)

Here is the result of conda list in the environment where the code fails:

# Name                    Version                   Build  Channel
alabaster                 0.7.12                   pypi_0    pypi
anyio                     2.2.0            py37haa95532_2
appdirs                   1.4.4                      py_0
arcgis                    1.9.0                 py37_2172    esri
arcgispro                 2.8                           0    esri
arcpy                     2.8             py37_arcgispro_29734  [arcgispro]  esri
argon2-cffi               20.1.0           py37h2bbff1b_1
arrow-cpp                 1.0.1                         3    esri
asn1crypto                1.4.0                      py_0
atomicwrites              1.4.0                      py_0
attrs                     21.2.0             pyhd3eb1b0_0
aws-c-common              0.4.57               ha925a31_1
aws-c-event-stream        0.1.6                hd77b12b_5
aws-checksums             0.1.9                ha925a31_0
aws-sdk-cpp               1.8.185              hd77b12b_0
azure-core                1.12.0                     py_0    esri
azure-storage-blob        12.8.0                     py_0    esri
babel                     2.9.1              pyhd3eb1b0_0
backcall                  0.2.0              pyhd3eb1b0_0
black                     19.10b0                    py_0
blas                      1.0                         mkl
bleach                    4.0.0              pyhd3eb1b0_0
blinker                   1.4              py37haa95532_0
bottleneck                1.3.2            py37h2a96729_1
brotlipy                  0.7.0           py37h2bbff1b_1003
bzip2                     1.0.8                he774522_0
ca-certificates           2021.7.5             haa95532_1
cached-property           1.5.2                      py_0
certifi                   2021.5.30        py37haa95532_0
cffi                      1.14.6           py37h2bbff1b_0
cfitsio                   3.470                he774522_6
cftime                    1.0.0b1                  py37_0    esri
chardet                   4.0.0           py37haa95532_1003
click                     7.1.2              pyhd3eb1b0_0
click-plugins             1.1.1                      py_0
cligj                     0.7.2                    pypi_0    pypi
colorama                  0.4.4              pyhd3eb1b0_0
cppzmq                    4.4.1                         2    esri
cryptography              3.4.7            py37h71e12ea_0
curl                      7.78.0               h86230a5_0
cycler                    0.10.0                   py37_0
decorator                 5.0.9              pyhd3eb1b0_0
defusedxml                0.7.1              pyhd3eb1b0_0
despatch                  0.1.0                    py37_0    esri
docutils                  0.17.1                   pypi_0    pypi
entrypoints               0.3                      py37_0
et_xmlfile                1.1.0            py37haa95532_0
expat                     2.4.1                h6c2663c_2
fastcache                 1.1.0            py37he774522_0
fiona                     1.8.4           py37h0d92105_1001    conda-forge
flake8                    3.9.2              pyhd3eb1b0_0
freetype                  2.10.1                   vc14_0  [vc14]  esri
freexl                    1.0.6                h2bbff1b_0
frictionless              4.16.2             pyh6c4a22f_0    conda-forge
future                    0.18.2                   py37_0    esri
gdal                      2.3.3           arcgispro_py37_16747  [arcgispro]  esri
geographiclib             1.52                     pypi_0    pypi
geopandas                 0.9.0                      py_1
geopandas-base            0.9.0                      py_1
geopy                     2.2.0                    pypi_0    pypi
geos                      3.8.0                h33f27b4_0
h5py                      2.10.0          py37_arcgispro_10  [arcgispro]  esri
hdf4                      4.2.13               h712560f_2
hdf5                      1.10.6               h7ebc959_0
html5lib                  1.1                        py_0
hypothesis                6.15.0             pyhd8ed1ab_0    conda-forge
icc_rt                    2019.0.5            arcgispro_0  [arcgispro]  esri
idna                      2.10               pyhd3eb1b0_0
imagesize                 1.2.0                    pypi_0    pypi
importlib-metadata        1.7.0                    pypi_0    pypi
importlib_metadata        3.10.0               hd3eb1b0_0
iniconfig                 1.1.1              pyhd3eb1b0_0
intel-openmp              2020.0            arcgispro_166  [arcgispro]  esri
ipykernel                 5.1.1                    py37_0    esri
ipython                   7.21.0                   py37_0    esri
ipython_genutils          0.2.0              pyhd3eb1b0_1
ipywidgets                7.4.2                    py37_0
isodate                   0.6.0                      py_0    esri
jdcal                     1.4.1                      py_0
jedi                      0.18.0                   py37_0    esri
jinja2                    3.0.1              pyhd3eb1b0_0
joblib                    1.0.1              pyhd3eb1b0_0
jpeg                      9d                            0    esri
json5                     0.9.4                    py37_0    esri
jsonschema                3.2.0                      py_2
jupyter_client            6.1.7                      py_0    esri
jupyter_console           6.2.0                      py_2    esri
jupyter_contrib_core      0.3.3                    py37_3    esri
jupyter_contrib_nbextensions 0.5.1                   py37_10    esri
jupyter_core              4.6.3                    py37_2    esri
jupyter_highlight_selected_word 0.2.0                    py37_2    esri
jupyter_latex_envs        1.4.4                    py37_1    esri
jupyter_nbextensions_configurator 0.4.1                    py37_1    esri
jupyter_server            1.5.1                    py37_0    esri
jupyterlab                3.1.7              pyhd3eb1b0_0
jupyterlab_server         2.7.1              pyhd3eb1b0_0
kealib                    1.4.14               hde4a422_0
keyring                   21.4.0                   py37_0    esri
kiwisolver                1.3.1            py37hd77b12b_0
krb5                      1.19.2               h5b6d351_0
lerc                      3.0                pyh39e3cac_0    esri
libcurl                   7.78.0               h86230a5_0
libiconv                  1.15                 h1df5818_7
libnetcdf                 4.6.1                hf59b723_4
libpng                    1.6.37               h2a8f88b_0
libpq                     12.2                 hb652d5d_1
libsodium                 1.0.18                        1    esri
libspatialindex           1.9.3                h6c2663c_0
libssh2                   1.9.0                h7a1dbc1_1
libtiff                   4.2.0                hd0e1b90_0
libxml2                   2.9.10              arcgispro_0  [arcgispro]  esri
libxslt                   1.1.34               he774522_0
lxml                      4.6.3            py37h9b66d53_0
lz4-c                     1.9.3                h2bbff1b_1
m2w64-expat               2.1.1                         2
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gettext             0.19.7                        2
m2w64-gmp                 6.1.0                         2
m2w64-libiconv            1.14                          6
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
m2w64-xz                  5.2.2                         2
mapclassify               2.4.3              pyhd3eb1b0_0
markupsafe                2.0.1            py37h2bbff1b_0
matplotlib                3.3.1           py37_arcgispro_0  [arcgispro]  esri
matplotlib-base           3.1.3            py37h64f37c6_0
mccabe                    0.6.1                    py37_1
mistune                   0.8.4           py37hfa6e2cd_1001
mkl                       2020.0            arcgispro_167  [arcgispro]  esri
mkl-service               2.3.0            py37h196d8e1_0
mkl_fft                   1.3.0            py37h46781fe_0
mkl_random                1.2.0                    py37_0    esri
mpmath                    1.2.1            py37haa95532_0
msrest                    0.6.21                     py_0    esri
msys2-conda-epoch         20160418                      1
munch                     2.5.0                      py_0
mypy_extensions           0.4.3                    py37_0
nbclassic                 0.2.6              pyhd3eb1b0_0
nbconvert                 5.6.1                    py37_0    esri
nbformat                  5.0.7                      py_1    esri
netcdf4                   1.5.4           py37_arcgispro_6  [arcgispro]  esri
networkx                  2.5                      py37_0    esri
nlohmann_json             3.7.0                         1    esri
nose                      1.3.7           pyhd3eb1b0_1006
notebook                  5.7.10                   py37_0
ntlm-auth                 1.4.0                      py_0    esri
numexpr                   2.7.3            py37hcbcaa1e_0
numpy                     1.20.1                   py37_0    esri
numpy-base                1.20.1                   py37_0    esri
oauthlib                  3.1.1              pyhd3eb1b0_0
olefile                   0.46                     py37_0
openjpeg                  2.3.0                h5ec785f_1
openpyxl                  3.0.7              pyhd3eb1b0_0
openssl                   1.1.1l               h2bbff1b_0
packaging                 21.0               pyhd3eb1b0_0
pandas                    1.2.4            py37hd77b12b_0
pandas-select             0.2.0                    pypi_0    pypi
pandera                   0.7.0              pyhd8ed1ab_0    conda-forge
pandocfilters             1.4.3            py37haa95532_1
parso                     0.8.2              pyhd3eb1b0_0
pathlib2                  2.3.6                    pypi_0    pypi
pathspec                  0.7.0                      py_0
pefile                    2019.4.18                  py_0
petl                      1.7.4              pyh44b312d_0    conda-forge
pickleshare               0.7.5           pyhd3eb1b0_1003
pillow-simd               8.2.0                    py37_1    esri
pip                       21.2.2           py37haa95532_0
pluggy                    0.13.1           py37haa95532_0
postgresql                12.2                 hb652d5d_1
pro_notebook_integration  2.8                      py37_0    esri
proj                      8.0.1                h1cfcee9_0    conda-forge
proj-data                 1.6                  hd8ed1ab_0    conda-forge
prometheus_client         0.8.0                      py_0    esri
prompt_toolkit            3.0.5                      py_0    esri
psutil                    5.8.0            py37h2bbff1b_1
py                        1.10.0             pyhd3eb1b0_0
pyarrow                   1.0.1                         2    esri
pybind11                  2.3.0                         1    esri
pycodestyle               2.7.0              pyhd3eb1b0_0
pycparser                 2.20                       py_2
pyflakes                  2.3.1              pyhd3eb1b0_0
pygments                  2.7.0                      py_0    esri
pyjwt                     2.1.0            py37haa95532_0
pyopenssl                 20.0.1             pyhd3eb1b0_1
pyparsing                 2.4.7              pyhd3eb1b0_0
pypdf2                    1.26.0                     py_2    esri
pypiwin32                 223                      pypi_0    pypi
pyproj                    3.1.0            py37h9f67652_4    conda-forge
pyrsistent                0.17.3           py37he774522_0
pyshp                     2.1.3              pyhd3eb1b0_0
pysocks                   1.7.1                    py37_1
pytest                    6.1.1                    py37_0    esri
python                    3.7.9                h60c2a47_0
python-certifi-win32      1.2                      py37_0    esri
python-dateutil           2.8.2              pyhd3eb1b0_0
python-slugify            5.0.2              pyhd8ed1ab_0    conda-forge
python_abi                3.7                     2_cp37m    conda-forge
pytz                      2021.1             pyhd3eb1b0_0
pywin32                   301                      pypi_0    pypi
pywin32-ctypes            0.2.0                    pypi_0    pypi
pywin32-security          228                      py37_3    esri
pywinpty                  0.5.7                    py37_0    esri
pyyaml                    5.4.1            py37h2bbff1b_1
pyzmq                     19.0.2                   py37_1    esri
regex                     2021.8.3         py37h2bbff1b_0
requests                  2.25.1             pyhd3eb1b0_0
requests-kerberos         0.12.0                        0    esri
requests-negotiate-sspi   0.5.2                    py37_1    esri
requests-oauthlib         1.3.0                      py_0
requests-toolbelt         0.9.1                      py_0
requests_ntlm             1.1.0                      py_0    esri
rfc3986                   1.5.0              pyhd8ed1ab_0    conda-forge
rtree                     0.9.7            py37h2eaa2aa_1
saspy                     3.6.1                      py_0    esri
scikit-learn              0.24.2           py37hf11a4ad_1
scipy                     1.6.2            py37h14eb087_0
send2trash                1.5.0              pyhd3eb1b0_1
setuptools                52.0.0           py37haa95532_0
shapely                   1.7.1                    pypi_0    pypi
shellingham               1.4.0              pyh44b312d_0    conda-forge
simpleeval                0.9.10           py37h4ab8f01_1    conda-forge
simplegeneric             0.8.1                    py37_2
six                       1.16.0             pyhd3eb1b0_0
sklearn                   0.0                      pypi_0    pypi
sniffio                   1.2.0            py37haa95532_1
snowballstemmer           2.1.0                    pypi_0    pypi
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
sphinx                    4.1.2                    pypi_0    pypi
sphinx-copybutton         0.3.3                    pypi_0    pypi
sphinxcontrib-applehelp   1.0.2                    pypi_0    pypi
sphinxcontrib-devhelp     1.0.2                    pypi_0    pypi
sphinxcontrib-htmlhelp    2.0.0                    pypi_0    pypi
sphinxcontrib-jsmath      1.0.1                    pypi_0    pypi
sphinxcontrib-qthelp      1.0.3                    pypi_0    pypi
sphinxcontrib-serializinghtml 1.1.5                    pypi_0    pypi
sqlite                    3.36.0               h2bbff1b_0
st-dbscan                 0.1.6                    pypi_0    pypi
stringcase                1.2.0                      py_0    conda-forge
swat                      1.8.1                    py37_0    esri
sympy                     1.5.1                    py37_0    esri
terminado                 0.9.4            py37haa95532_0
testpath                  0.5.0              pyhd3eb1b0_0
text-unidecode            1.3                        py_0    conda-forge
threadpoolctl             2.2.0              pyhbf3da8f_0
tiledb                    2.2.9                hf7ce2e6_0
toml                      0.10.2             pyhd3eb1b0_0
tornado                   6.1              py37h2bbff1b_0
tqdm                      4.62.2                   pypi_0    pypi
traitlets                 4.3.3                    py37_0
typed-ast                 1.4.3            py37h2bbff1b_1
typer                     0.3.2              pyhd8ed1ab_0    conda-forge
typing-extensions         3.10.0.0             hd3eb1b0_0
typing_extensions         3.10.0.0           pyh06a4308_0
typing_inspect            0.7.1              pyh6c4a22f_0    conda-forge
ujson                     4.0.2            py37hd77b12b_0
unidecode                 1.2.0              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.6             pyhd3eb1b0_1
validators                0.18.2             pyhd3deb0d_0    conda-forge
vc                        14.2                 h21ff451_1
vs2015_runtime            14.27.29016          h5e58377_2
wcwidth                   0.2.5                      py_0
webencodings              0.5.1                    py37_1
wheel                     0.37.0             pyhd3eb1b0_0
widgetsnbextension        3.4.2                    py37_0
win10toast                0.9                      pypi_0    pypi
win_inet_pton             1.1.0            py37haa95532_0
wincertstore              0.2                      py37_0
winkerberos               0.7.0                    py37_0    esri
winpty                    0.4.3                         4
wrapt                     1.12.1           py37he774522_1
x86cpu                    0.4                      py37_1    esri
xarray                    0.19.0             pyhd3eb1b0_1
xerces-c                  3.2.3                ha925a31_0
xeus                      0.24.1                        1    esri
xlrd                      1.2.0                    py37_0
xlwt                      1.3.0                    py37_0
xtl                       0.6.5                         1    esri
xz                        5.2.5                h62dcd97_0
yaml                      0.2.5                         0    esri
zeromq                    4.3.2                         2    esri
zipp                      3.5.0              pyhd3eb1b0_0
zlib                      1.2.11               h62dcd97_4
zope-interface            5.4.0                    pypi_0    pypi
zstd                      1.4.9                h19a0ad4_0

I tried posting my installed packages for the environment where the code works, but hit the SE character limit. Note that datetime isn't installed in that environment either, and the python and arcgis versions are the same.

5
  • Have you tried to install datetime in the virtual environment? conda install datetime or pip install datetime
    – Encomium
    Sep 23, 2021 at 19:13
  • 1
    @Encomium - I could be wrong but I think datetime is built-in to python: stackoverflow.com/questions/58531236/…. pip install datetime installs a different DateTime module: pypi.org/project/DateTime. I originally had that module in the error env, so I thought that was the issue -- but the error persists even after deleting it.
    – CGP
    Sep 23, 2021 at 19:37
  • 1
    @ChadPeltier have the exact same issue. Any solution?
    – dgrubman
    Oct 19, 2021 at 21:31
  • Unfortunately no. I switched to the environment where it works without crashing, so I haven't traced the actual problem yet. I tried comparing the packages in each environment to see any differences in package versions, but nothing obvious stood out (versions of Python, arcpy, arcgis, datetime, etc.).
    – CGP
    Oct 20, 2021 at 13:13
  • I eventually just deleted all conda environments from my machine and also upgraded Pro to v2.9, and I'm no longer getting this error. Unfrotunately it's unclear whether it was a problem with my conda environments or something in the verision of Pro/arcgis API for Python -- but either way, it seems to work now.
    – CGP
    Dec 2, 2021 at 19:59

0