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

Segmentation fault when importing PUDL installed from conda-forge #2426

Closed
2 tasks
arengel opened this issue Mar 20, 2023 · 22 comments
Closed
2 tasks

Segmentation fault when importing PUDL installed from conda-forge #2426

arengel opened this issue Mar 20, 2023 · 22 comments
Assignees
Labels
bug Things that are just plain broken. dependencies Pull requests that update a dependency file
Milestone

Comments

@arengel
Copy link
Collaborator

arengel commented Mar 20, 2023

Describe the bug

I just re-created a new conda environment where I installed PUDL from conda-forge. When I import PUDL in that environment, it results in a segmentation fault.

The last time I installed PUDL from conda-forge, this didn't happen, though I can't say for sure when that would have been.

Bug Severity

How badly is this bug affecting you?

  • Low: When installed using pip, this doesn't seem to happen so I can work around it.

To Reproduce

Create the new environment, install PUDL, activate the environment, and launch a python console.

mamba create --name test python=3.10 catalystcoop.pudl
mamba activate test
python

In the console, import PUDL

import pudl

The console then produces this output and exits.

/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/pudl/analysis/spatial.py:7: UserWarning: Shapely 2.0 is installed, but because PyGEOS is also installed, GeoPandas will still use PyGEOS by default for now. To force to use and test Shapely 2.0, you have to set the environment variable USE_PYGEOS=0. You can do this before starting the Python process, or in your code before importing geopandas:

import os
os.environ['USE_PYGEOS'] = '0'
import geopandas

In a future release, GeoPandas will switch to using Shapely by default. If you are using PyGEOS directly (calling PyGEOS functions on geometries from GeoPandas), this will then stop working and you are encouraged to migrate from PyGEOS to Shapely 2.0 (https://shapely.readthedocs.io/en/latest/migration_pygeos.html).
  import geopandas as gpd
zsh: segmentation fault  python

Software Environment?

  • Operating System. MacOS 12.6.3
  • Python 3.10.9 | packaged by conda-forge | (main, Feb 2 2023, 20:26:08) [Clang 14.0.6 ] on darwin
  • How did you install PUDL?
    • mamba create --name test python=3.10 catalystcoop.pudl

Full set of packages and versions:

# packages in environment at /Users/aengel/mambaforge/envs/test:
#
# Name                    Version                   Build  Channel
addfips                   0.4.0              pyhd8ed1ab_1    conda-forge
aiohttp                   3.8.4           py310h8e9501a_0    conda-forge
aiosignal                 1.3.1              pyhd8ed1ab_0    conda-forge
arelle-release            2.2.4              pyhd8ed1ab_1    conda-forge
arrow-cpp                 10.0.1          hce30654_17_cpu    conda-forge
async-timeout             4.0.2              pyhd8ed1ab_0    conda-forge
attrs                     22.2.0             pyh71513ae_0    conda-forge
aws-c-auth                0.6.26               h0f48f9c_0    conda-forge
aws-c-cal                 0.5.21               h134b2d6_2    conda-forge
aws-c-common              0.8.14               h1a8c8d9_0    conda-forge
aws-c-compression         0.2.16               h59b28b2_5    conda-forge
aws-c-event-stream        0.2.20               ha370d96_4    conda-forge
aws-c-http                0.7.5                hca61f3c_5    conda-forge
aws-c-io                  0.13.19              ha2443f3_1    conda-forge
aws-c-mqtt                0.8.6               hcfee220_11    conda-forge
aws-c-s3                  0.2.7                h050892e_0    conda-forge
aws-c-sdkutils            0.1.8                h59b28b2_0    conda-forge
aws-checksums             0.1.14               h59b28b2_5    conda-forge
aws-crt-cpp               0.19.8              h0287f93_11    conda-forge
aws-sdk-cpp               1.10.57              h3daea3c_8    conda-forge
blinker                   1.5                pyhd8ed1ab_0    conda-forge
blosc                     1.21.3               h1d6ff8b_0    conda-forge
bokeh                     2.4.3              pyhd8ed1ab_3    conda-forge
boost-cpp                 1.78.0               h1cb353e_1    conda-forge
boto3                     1.26.94            pyhd8ed1ab_0    conda-forge
botocore                  1.29.94            pyhd8ed1ab_0    conda-forge
branca                    0.6.0              pyhd8ed1ab_0    conda-forge
brotli                    1.0.9                h1a8c8d9_8    conda-forge
brotli-bin                1.0.9                h1a8c8d9_8    conda-forge
brotlipy                  0.7.0           py310h8e9501a_1005    conda-forge
bzip2                     1.0.8                h3422bc3_4    conda-forge
c-ares                    1.18.1               h3422bc3_0    conda-forge
ca-certificates           2022.12.7            h4653dfc_0    conda-forge
cached-property           1.5.2                hd8ed1ab_1    conda-forge
cached_property           1.5.2              pyha770c72_1    conda-forge
cachetools                5.3.0              pyhd8ed1ab_0    conda-forge
cairo                     1.16.0            h73a0509_1014    conda-forge
catalystcoop.dbfread      3.0.0                      py_0    conda-forge
catalystcoop.ferc-xbrl-extractor 0.6.1              pyhd8ed1ab_1    conda-forge
catalystcoop.pudl         2022.11.30         pyhd8ed1ab_0    conda-forge
cchardet                  2.1.7           py310h0f1eb42_4    conda-forge
certifi                   2022.12.7          pyhd8ed1ab_0    conda-forge
cffi                      1.15.1          py310h2399d43_3    conda-forge
cfitsio                   4.2.0                h2f961c4_0    conda-forge
chardet                   5.1.0           py310hbe9552e_0    conda-forge
charset-normalizer        2.1.1              pyhd8ed1ab_0    conda-forge
click                     8.1.3           unix_pyhd8ed1ab_2    conda-forge
click-plugins             1.1.1                      py_0    conda-forge
cligj                     0.7.2              pyhd8ed1ab_1    conda-forge
cloudpickle               2.2.1              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
coloredlogs               15.0.1             pyhd8ed1ab_3    conda-forge
commonmark                0.9.1                      py_0    conda-forge
contourpy                 1.0.7           py310h2887b22_0    conda-forge
cryptography              39.0.2          py310hfc83b78_0    conda-forge
curl                      7.88.1               h9049daf_1    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
cytoolz                   0.12.0          py310h8e9501a_1    conda-forge
dask                      2022.11.1          pyhd8ed1ab_0    conda-forge
dask-core                 2022.11.1          pyhd8ed1ab_0    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
datapackage               1.15.2             pyh44b312d_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
distributed               2022.11.1          pyhd8ed1ab_0    conda-forge
dnspython                 2.3.0              pyhd8ed1ab_0    conda-forge
email-validator           1.3.1              pyhd8ed1ab_0    conda-forge
et_xmlfile                1.1.0              pyhd8ed1ab_0    conda-forge
expat                     2.5.0                hb7217d7_0    conda-forge
fiona                     1.9.2           py310h2e51ddd_0    conda-forge
folium                    0.14.0             pyhd8ed1ab_0    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.2               h82840c6_0    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
fonttools                 4.39.2          py310h8e9501a_0    conda-forge
freetype                  2.12.1               hd633e50_1    conda-forge
freexl                    1.0.6                h1a8c8d9_1    conda-forge
frictionless              4.40.8             pyh6c4a22f_0    conda-forge
frozenlist                1.3.3           py310h8e9501a_0    conda-forge
fsspec                    2022.11.0          pyhd8ed1ab_0    conda-forge
future                    0.18.3             pyhd8ed1ab_0    conda-forge
gcsfs                     2022.11.0          pyhd8ed1ab_0    conda-forge
gdal                      3.6.3           py310h0b34360_0    conda-forge
geopandas                 0.12.2             pyhd8ed1ab_0    conda-forge
geopandas-base            0.12.2             pyha770c72_0    conda-forge
geos                      3.11.1               hb7217d7_0    conda-forge
geotiff                   1.7.1                h435296a_7    conda-forge
gettext                   0.21.1               h0186832_0    conda-forge
gflags                    2.2.2             hc88da5d_1004    conda-forge
giflib                    5.2.1                h1a8c8d9_3    conda-forge
glog                      0.6.0                h6da1cb0_0    conda-forge
google-api-core           2.11.0             pyhd8ed1ab_0    conda-forge
google-auth               2.16.2             pyh1a96a4e_0    conda-forge
google-auth-oauthlib      1.0.0              pyhd8ed1ab_0    conda-forge
google-cloud-core         2.3.2              pyhd8ed1ab_0    conda-forge
google-cloud-storage      2.7.0              pyh1a96a4e_0    conda-forge
google-crc32c             1.1.2           py310he58995c_4    conda-forge
google-resumable-media    2.4.1              pyhd8ed1ab_0    conda-forge
googleapis-common-protos  1.57.1             pyhd8ed1ab_0    conda-forge
greenlet                  2.0.2           py310h0f1eb42_0    conda-forge
grpcio                    1.52.1          py310h0f1eb42_1    conda-forge
h3-py                     3.7.4           py310h0f1eb42_1    conda-forge
hdf4                      4.2.15               h8111dcc_6    conda-forge
hdf5                      1.12.2          nompi_ha7af310_101    conda-forge
heapdict                  1.0.1                      py_0    conda-forge
humanfriendly             10.0            py310hbe9552e_4    conda-forge
icu                       70.1                 h6b3803e_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
ijson                     3.2.0.post0        pyhd8ed1ab_0    conda-forge
importlib-metadata        6.1.0              pyha770c72_0    conda-forge
importlib_resources       5.12.0             pyhd8ed1ab_0    conda-forge
iniconfig                 2.0.0              pyhd8ed1ab_0    conda-forge
isodate                   0.6.1              pyhd8ed1ab_0    conda-forge
jinja2                    3.1.2              pyhd8ed1ab_1    conda-forge
jmespath                  1.0.1              pyhd8ed1ab_0    conda-forge
joblib                    1.2.0              pyhd8ed1ab_0    conda-forge
json-c                    0.16                 hc449e50_0    conda-forge
jsonlines                 3.1.0              pyhd8ed1ab_0    conda-forge
jsonpointer               2.0                        py_0    conda-forge
jsonschema                4.17.3             pyhd8ed1ab_0    conda-forge
kealib                    1.5.0                hfd766a6_0    conda-forge
kiwisolver                1.4.4           py310h2887b22_1    conda-forge
krb5                      1.20.1               h69eda48_0    conda-forge
lcms2                     2.15                 hd835a16_1    conda-forge
lerc                      4.0.0                h9a09cb3_0    conda-forge
libabseil                 20230125.0      cxx17_hb7217d7_1    conda-forge
libaec                    1.0.6                hb7217d7_1    conda-forge
libarrow                  10.0.1          hdcd110a_17_cpu    conda-forge
libblas                   3.9.0           16_osxarm64_openblas    conda-forge
libbrotlicommon           1.0.9                h1a8c8d9_8    conda-forge
libbrotlidec              1.0.9                h1a8c8d9_8    conda-forge
libbrotlienc              1.0.9                h1a8c8d9_8    conda-forge
libcblas                  3.9.0           16_osxarm64_openblas    conda-forge
libcrc32c                 1.1.2                hbdafb3b_0    conda-forge
libcurl                   7.88.1               h9049daf_1    conda-forge
libcxx                    15.0.7               h75e25f2_0    conda-forge
libdeflate                1.17                 h1a8c8d9_0    conda-forge
libedit                   3.1.20191231         hc8eb9b7_2    conda-forge
libev                     4.33                 h642e427_1    conda-forge
libevent                  2.1.10               h7673551_4    conda-forge
libffi                    3.4.2                h3422bc3_5    conda-forge
libgdal                   3.6.3                h2c41457_0    conda-forge
libgfortran               5.0.0           12_2_0_hd922786_31    conda-forge
libgfortran5              12.2.0              h0eea778_31    conda-forge
libglib                   2.74.1               h4646484_1    conda-forge
libgoogle-cloud           2.8.0                h7206bc8_1    conda-forge
libgrpc                   1.52.1               he98ff75_1    conda-forge
libiconv                  1.17                 he4db4b2_0    conda-forge
libjpeg-turbo             2.1.5.1              h1a8c8d9_0    conda-forge
libkml                    1.3.0             h41464e4_1015    conda-forge
liblapack                 3.9.0           16_osxarm64_openblas    conda-forge
libllvm11                 11.1.0               hfa12f05_5    conda-forge
libnetcdf                 4.9.1           nompi_hda66dd9_102    conda-forge
libnghttp2                1.52.0               hae82a92_0    conda-forge
libopenblas               0.3.21          openmp_hc731615_3    conda-forge
libpng                    1.6.39               h76d750c_0    conda-forge
libpq                     15.2                 h1a28acd_0    conda-forge
libprotobuf               3.21.12              hb5ab8b9_0    conda-forge
librttopo                 1.1.0               h844f84d_12    conda-forge
libspatialindex           1.9.3                hbdafb3b_4    conda-forge
libspatialite             5.0.1               h14115fc_23    conda-forge
libsqlite                 3.40.0               h76d750c_0    conda-forge
libssh2                   1.10.0               h7a5bd25_3    conda-forge
libthrift                 0.18.1               h6635e49_0    conda-forge
libtiff                   4.5.0                hdc14d85_5    conda-forge
libutf8proc               2.8.0                h1a8c8d9_0    conda-forge
libwebp-base              1.3.0                h1a8c8d9_0    conda-forge
libxcb                    1.13              h9b22ae9_1004    conda-forge
libxml2                   2.10.3               h67585b2_4    conda-forge
libxslt                   1.1.37               h1bd8bc4_0    conda-forge
libzip                    1.9.2                h76ab92c_1    conda-forge
libzlib                   1.2.13               h03a7124_4    conda-forge
linear-tsv                1.1.0                      py_1    conda-forge
llvm-openmp               16.0.0               h7cfbb63_0    conda-forge
llvmlite                  0.39.1          py310h1e34944_1    conda-forge
locket                    1.0.0              pyhd8ed1ab_0    conda-forge
lxml                      4.9.2           py310h85b680a_0    conda-forge
lz4                       4.3.2           py310ha6df754_0    conda-forge
lz4-c                     1.9.4                hb7217d7_0    conda-forge
mapclassify               2.5.0              pyhd8ed1ab_1    conda-forge
marko                     1.3.0              pyhd8ed1ab_0    conda-forge
markupsafe                2.1.2           py310h8e9501a_0    conda-forge
matplotlib-base           3.6.3           py310h78c5c2f_0    conda-forge
msgpack-python            1.0.5           py310h2887b22_0    conda-forge
multidict                 6.0.4           py310h8e9501a_0    conda-forge
munch                     2.5.0                      py_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
ncurses                   6.3                  h07bb92c_1    conda-forge
networkx                  2.8.8              pyhd8ed1ab_0    conda-forge
nspr                      4.35                 hb7217d7_0    conda-forge
nss                       3.89                 h789eff7_0    conda-forge
numba                     0.56.4          py310h3124f1e_0    conda-forge
numpy                     1.23.5          py310h5d7c261_0    conda-forge
oauthlib                  3.2.2              pyhd8ed1ab_0    conda-forge
openjpeg                  2.5.0                hbc2ba62_2    conda-forge
openpyxl                  3.1.1           py310h8e9501a_0    conda-forge
openssl                   3.1.0                h03a7124_0    conda-forge
orc                       1.8.3                hef0d403_0    conda-forge
packaging                 23.0               pyhd8ed1ab_0    conda-forge
pandas                    1.4.4           py310h2b830bf_0    conda-forge
parquet-cpp               1.5.1                         2    conda-forge
partd                     1.3.0              pyhd8ed1ab_0    conda-forge
pcre2                     10.40                hb34f9b4_0    conda-forge
petl                      1.7.12             pyhd8ed1ab_0    conda-forge
pillow                    9.4.0           py310h07496d3_2    conda-forge
pip                       23.0.1             pyhd8ed1ab_0    conda-forge
pixman                    0.40.0               h27ca646_0    conda-forge
pkgutil-resolve-name      1.3.10             pyhd8ed1ab_0    conda-forge
pluggy                    1.0.0              pyhd8ed1ab_5    conda-forge
poppler                   23.03.0              h15f6d88_1    conda-forge
poppler-data              0.4.12               hd8ed1ab_0    conda-forge
postgresql                15.2                 h45c140d_0    conda-forge
proj                      9.1.1                h13f728c_2    conda-forge
protobuf                  4.21.12         py310h0f1eb42_0    conda-forge
psutil                    5.9.4           py310h8e9501a_0    conda-forge
pthread-stubs             0.4               h27ca646_1001    conda-forge
py                        1.11.0             pyh6c4a22f_0    conda-forge
pyarrow                   10.0.1          py310h89f3c6b_17_cpu    conda-forge
pyasn1                    0.4.8                      py_0    conda-forge
pyasn1-modules            0.2.7                      py_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pydantic                  1.10.6          py310h8e9501a_0    conda-forge
pygeos                    0.13            py310h9356385_2    conda-forge
pygments                  2.14.0             pyhd8ed1ab_0    conda-forge
pyjwt                     2.6.0              pyhd8ed1ab_0    conda-forge
pyopenssl                 23.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyproj                    3.4.1           py310h9862ddf_1    conda-forge
pyrsistent                0.19.3          py310h8e9501a_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
pytest                    6.2.5           py310hbe9552e_3    conda-forge
python                    3.10.9          h3ba56d0_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-slugify            8.0.1              pyhd8ed1ab_1    conda-forge
python-snappy             0.6.1           py310h7f31a72_0    conda-forge
python_abi                3.10                    3_cp310    conda-forge
pytz                      2022.7.1           pyhd8ed1ab_0    conda-forge
pyu2f                     0.1.5              pyhd8ed1ab_0    conda-forge
pyyaml                    6.0             py310h8e9501a_5    conda-forge
re2                       2023.02.02           hb7217d7_0    conda-forge
readline                  8.1.2                h46ed386_0    conda-forge
regex                     2022.10.31      py310h8e9501a_0    conda-forge
requests                  2.28.2             pyhd8ed1ab_0    conda-forge
requests-oauthlib         1.3.1              pyhd8ed1ab_0    conda-forge
rfc3986                   2.0.0              pyhd8ed1ab_0    conda-forge
rich                      12.6.0             pyhd8ed1ab_0    conda-forge
rsa                       4.9                pyhd8ed1ab_0    conda-forge
rtree                     1.0.1           py310ha3239f5_1    conda-forge
s3transfer                0.6.0              pyhd8ed1ab_0    conda-forge
scikit-learn              1.1.3           py310ha00a7cd_1    conda-forge
scipy                     1.9.3           py310ha0d8a01_2    conda-forge
setuptools                67.6.0             pyhd8ed1ab_0    conda-forge
shapely                   2.0.1           py310h9356385_0    conda-forge
shellingham               1.5.1              pyhd8ed1ab_0    conda-forge
simpleeval                0.9.13          py310h8e9501a_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
snappy                    1.1.10               h17c5cce_0    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
sqlalchemy                1.4.44          py310h8e9501a_0    conda-forge
sqlite                    3.40.0               h2229b38_0    conda-forge
stringcase                1.2.0                      py_0    conda-forge
tableschema               1.19.3             pyh9f0ad1d_0    conda-forge
tabulate                  0.9.0              pyhd8ed1ab_1    conda-forge
tabulator                 1.53.5             pyhd8ed1ab_0    conda-forge
tblib                     1.7.0              pyhd8ed1ab_0    conda-forge
text-unidecode            1.3                        py_0    conda-forge
threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
tiledb                    2.13.2               h9bd36d0_0    conda-forge
timezonefinder            6.0.2              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               he1e0b03_0    conda-forge
toml                      0.10.2             pyhd8ed1ab_0    conda-forge
toolz                     0.12.0             pyhd8ed1ab_0    conda-forge
tornado                   6.1             py310hf8d0d8f_3    conda-forge
typer                     0.7.0              pyhd8ed1ab_0    conda-forge
typing-extensions         4.5.0                hd8ed1ab_0    conda-forge
typing_extensions         4.5.0              pyha770c72_0    conda-forge
tzcode                    2022g                h1a8c8d9_0    conda-forge
tzdata                    2022g                h191b570_0    conda-forge
unicodecsv                0.14.1                     py_1    conda-forge
unicodedata2              15.0.0          py310h8e9501a_0    conda-forge
unidecode                 1.3.6              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.15            pyhd8ed1ab_0    conda-forge
validators                0.20.0             pyhd8ed1ab_0    conda-forge
wheel                     0.40.0             pyhd8ed1ab_0    conda-forge
xerces-c                  3.2.4                h627aa08_1    conda-forge
xlrd                      2.0.1              pyhd8ed1ab_3    conda-forge
xlsxwriter                3.0.9              pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.9                h27ca646_0    conda-forge
xorg-libxdmcp             1.1.3                h27ca646_0    conda-forge
xyzservices               2023.2.0           pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h57fd34a_0    conda-forge
yaml                      0.2.5                h3422bc3_2    conda-forge
yarl                      1.8.2           py310h8e9501a_0    conda-forge
zict                      2.2.0              pyhd8ed1ab_0    conda-forge
zipp                      3.15.0             pyhd8ed1ab_0    conda-forge
zlib                      1.2.13               h03a7124_4    conda-forge
zstd                      1.5.2                hf913c23_6    conda-forge

Additional context

Add any other context about the problem here.

========
edit from @jdangerx

Scope

Next steps

@arengel arengel added the bug Things that are just plain broken. label Mar 20, 2023
@zaneselvans
Copy link
Member

I am able to reproduce this. Seems very bad! What the heck?!

I doubt it's related, but I get the same behavior (albeit faster!) if I export USE_PYGEOS=0 before firing up the python prompt.

@arengel
Copy link
Collaborator Author

arengel commented Mar 21, 2023

I found a suggestion on stackoverflow to use faulthandler to track down where the issue is occurring.

From the full results which are below, it looks like the problem is happening in h3 which is a dependency of timezonefinder. And indeed, when I import either of those, I get the same segmentation fault.

Confirmed in issue uber/h3-py#313.

import faulthandler
faulthandler.enable()
import timezonefinder
Fatal Python error: Segmentation fault

Current thread 0x0000000100aac580 (most recent call first):
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 1176 in create_module
  File "<frozen importlib._bootstrap>", line 571 in module_from_spec
  File "<frozen importlib._bootstrap>", line 674 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/h3/_cy/__init__.py", line 16 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1078 in _handle_fromlist
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/h3/api/basic_int/_binding.py", line 16 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/h3/api/basic_int/_public_api.py", line 9 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/h3/api/basic_int/__init__.py", line 1 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1078 in _handle_fromlist
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/h3/api/__init__.py", line 3 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 992 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/h3/__init__.py", line 3 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 992 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/timezonefinder/timezonefinder.py", line 10 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "/Users/aengel/mambaforge/envs/test/lib/python3.10/site-packages/timezonefinder/__init__.py", line 2 in <module>
  File "<frozen importlib._bootstrap>", line 241 in _call_with_frames_removed
  File "<frozen importlib._bootstrap_external>", line 883 in exec_module
  File "<frozen importlib._bootstrap>", line 688 in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1006 in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1027 in _find_and_load
  File "<stdin>", line 1 in <module>

Extension modules: numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator (total: 13)
zsh: segmentation fault  python

@zaneselvans
Copy link
Member

Thank you for that sleuthing! It's disturbing that the issue has been open for a month with no resolution.

@jdangerx
Copy link
Member

@arengel - FYI, for internal planning purposes I'm going to edit this issue to include a 'scope' and 'next steps' section. (Thanks for bringing this up!)

@zaneselvans
Copy link
Member

It looks like there was some work on the H3 conda-forge feedstock to try and fix this but it petered out.

@jdangerx
Copy link
Member

We'd like to work on this but not necessarily blow up our whole sprint working on this.

Scope

  • the version of the code that you install from conda-forge successfully runs ETL locally

Out of scope:

  • running a new data release

Next steps

  • branch off of the commit that's published on conda-forge and pin dependencies until the segfault goes away

@nelsonauner
Copy link
Contributor

I'm interested in helping but am on WSL, not mac...

@jdangerx jdangerx self-assigned this Mar 27, 2023
@nelsonauner
Copy link
Contributor

Replicated on a new M2 Macbook air, will play around with this a bit...

@zaneselvans
Copy link
Member

Seems like it's probably a bunch of dependency futzing. We've considered using conda-lock to lock exact versions of all of our dependencies so this kind of drift after the fact can't happen, if that's something you feel like exploring!

@nelsonauner
Copy link
Contributor

Locking dependancies makes total sense and is why I've always used a pinned requirements.txt or Pipfile.lock. I'll give this a shot!

@zaneselvans
Copy link
Member

We have some annoying to build dependencies that need C/C++/Fortran extensions (e.g. geospatial stuff) and some non-python dependencies that conda can satisfy without needing to resort to using Docker or other heavier weight environment management systems (e.g. the snappy compression library, SQLite binaries) and it's also nice to use the conda supplied Python rather than hope that the user has the right version of Python available on their system. At least in development we've primarily used conda for environment virtualization, with the PUDL package getting installed within that environment by pip.

@zaneselvans
Copy link
Member

(also I have a PR (#2479) open right now to move all our project metadata / build stuff into pyproject.toml and get rid of setup.py finally.

@jdangerx
Copy link
Member

jdangerx commented Apr 3, 2023 via email

@zaneselvans zaneselvans added this to the 2023Q2 milestone Apr 4, 2023
@nelsonauner
Copy link
Contributor

All right, I got something working!
It looks like the conda-forge maintainers will fix the root cause but until then this workaround uses pip to install a more recent version of h3-py.

I also implemented conda-lock which I think will be a great way to better track dependancies. However I mamba is so much faster that might make sense to let users decide if they prefer more deterministic locking or faster, sloppier locking

Using pure mamba and environment.yml

# mamba does not support creating from an environment.yml file, so create and then update:
mamba env create --name test
mamba env update -n test --file  environment.yml

Using conda-lock to create lockfiles

conda-lock -f environment.yml -p osx-64 -p linux-64 -p osx-arm64

Using conda-lock.yml to install from scratch 😄

(base) ➜  pudl git:(main) ✗ conda-lock install --name fromlock conda-lock.yml
WARNING:conda_lock.conda_lock:WARNING: installation of pip dependencies is only supported by the 'conda-lock install' command. Other tools may silently ignore them. For portability, we recommend using the newer unified lockfile format (i.e. removing the --kind=explicit argument.
INFO:root:Downloading and Extracting Packages
INFO:root:Downloading and Extracting Packages
INFO:root:Preparing transaction: ...working... done
INFO:root:Verifying transaction: ...working... done
INFO:root:Executing transaction: ...working... done
INFO:root:Collecting h3@ https://files.pythonhosted.org/packages/51/4b/31ed29f5dca2093f6e29707dc21b0cf7071de4623ade7491bd2ee191617d/h3-3.7.6-cp310-cp310-macosx_11_0_arm64.whl#sha256=8bf1e080b9a47774754834e7f10155f3d2e3542bf895488a0519b2ae7d5b15db
INFO:root:  Using cached h3-3.7.6-cp310-cp310-macosx_11_0_arm64.whl (904 kB)
INFO:root:Installing collected packages: h3
INFO:root:  Attempting uninstall: h3
INFO:root:    Found existing installation: h3 3.7.4
INFO:root:    Uninstalling h3-3.7.4:
INFO:root:      Successfully uninstalled h3-3.7.4
INFO:root:Successfully installed h3-3.7.6
INFO:root:
(base) ➜  pudl git:(main) ✗ conda activate fromlock
(fromlock) ➜  pudl git:(main) ✗ python
Python 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:12:31) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pudl
/Users/nelsonauner/mambaforge/envs/fromlock/lib/python3.10/site-packages/pudl/analysis/spatial.py:7: UserWarning: Shapely 2.0 is installed, but because PyGEOS is also installed, GeoPandas will still use PyGEOS by default for now. To force to use and test Shapely 2.0, you have to set the environment variable USE_PYGEOS=0. You can do this before starting the Python process, or in your code before importing geopandas:

import os
os.environ['USE_PYGEOS'] = '0'
import geopandas

In a future release, GeoPandas will switch to using Shapely by default. If you are using PyGEOS directly (calling PyGEOS functions on geometries from GeoPandas), this will then stop working and you are encouraged to migrate from PyGEOS to Shapely 2.0 (https://shapely.readthedocs.io/en/latest/migration_pygeos.html).
  import geopandas as gpd
>>>  #works! no segfault

nelsonauner added a commit to nelsonauner/pudl that referenced this issue Apr 5, 2023
… silicon

Signed-off-by: Nelson Auner <nelson@auner.org>
nelsonauner added a commit to nelsonauner/pudl that referenced this issue Apr 5, 2023
… silicon

Signed-off-by: Nelson Auner <nelson@auner.org>
nelsonauner added a commit to nelsonauner/pudl that referenced this issue Apr 6, 2023
@zaneselvans
Copy link
Member

This should hopefully be fixed by v2022.11.30.post1 which I will get up on conda-forge some time tomorrow (once their bot has picked up the new PyPI release)

@zaneselvans zaneselvans added the dependencies Pull requests that update a dependency file label Apr 6, 2023
@zaneselvans
Copy link
Member

I may have spoken too soon here. Unfortunately the only version of h3-py that is available via conda is 3.7.4, which is the one that was giving us problems.

$ mamba search h3-py
# Name                       Version           Build  Channel
h3-py                          3.7.4 py310h0f1eb42_1  conda-forge
h3-py                          3.7.4 py311ha397e9f_1  conda-forge
h3-py                          3.7.4  py38h2b1e499_1  conda-forge
h3-py                          3.7.4  py39h23fbdae_1  conda-forge

@jdangerx
Copy link
Member

jdangerx commented Apr 10, 2023

Maybe h3-py 3.7.4 only works on Python 3.10? My next guess would be to try to reproduce this issue in 3.10 vs. 3.11...

https://github.com/uber/h3-py/blob/master/CHANGELOG.md#374---2022-04-14

@nelsonauner
Copy link
Contributor

For those following along, this is still an issue given that h3-py is still not updated on conda (but is on pip).

This issue can be "patched" simply by, after running the conda install, using pip to update h3-py:

# Install and activate environmentmamba create --name test python=3.10 catalystcoop.pudlconda activate test

# Load python and attempt to import `pudl`:
(test) ➜ python
Python 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:12:31) [Clang 14.0.6 ] on darwin
>>> import pudl
....
[1]    96656 segmentation fault  python

# Show that we're using virtual env pip and update the h3 module: 
(test) ➜  pudl git:(pandas-2.0) ✗ which pip
/Users/nelsonauner/mambaforge/envs/test/bin/pip
(test) ➜  pudl git:(pandas-2.0) ✗ pip install "h3>=3.7.6,<3.8"
Collecting h3<3.8,>=3.7.6
  Using cached h3-3.7.6-cp310-cp310-macosx_11_0_arm64.whl (904 kB)
Installing collected packages: h3
  Attempting uninstall: h3
    Found existing installation: h3 3.7.4
    Uninstalling h3-3.7.4:
      Successfully uninstalled h3-3.7.4
Successfully installed h3-3.7.6

# Now it works

@nelsonauner
Copy link
Contributor

@zaneselvans @arengel

Great news - https://anaconda.org/conda-forge/h3-py was updated over the weekend to 3.7.6 and now works totally fine:

Zane - can you close this if everything here looks fine? I would at some point love to pick up convo on versioning we had in #2497 but lower priority than upgrading pandas 2.0

(base) ➜  pudl git:(dev) ✗ mamba create --name test-update  python=3.10 catalystcoop.pudl
# ...   + h3-py                                    3.7.6  py310h0f1eb42_0       conda-forge/osx-arm64      298kB 
(base) ➜  pudl git:(dev) ✗ conda activate test-update
(test-update) ➜  pudl git:(dev) ✗ python
Python 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:12:31) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pudl
/Users/nelsonauner/mambaforge/envs/test-update/lib/python3.10/site-packages/pudl/analysis/spatial.py:7: UserWarning: Shapely 2.0 is installed, but because PyGEOS is also installed, GeoPandas will still use PyGEOS by default for now. To force to use and test Shapely 2.0, you have to set the environment variable USE_PYGEOS=0. You can do this before starting the Python process, or in your code before importing geopandas:

import os
os.environ['USE_PYGEOS'] = '0'
import geopandas

In a future release, GeoPandas will switch to using Shapely by default. If you are using PyGEOS directly (calling PyGEOS functions on geometries from GeoPandas), this will then stop working and you are encouraged to migrate from PyGEOS to Shapely 2.0 (https://shapely.readthedocs.io/en/latest/migration_pygeos.html).
  import geopandas as gpd
>>> print("it works, hooray!!")
it works, hooray!!

@zaneselvans
Copy link
Member

Oh great!

Does this mean that the post1 release we tried to get going on conda is no longer necessary, since it'll automatically pick up the newer version of h3-py?

@nelsonauner
Copy link
Contributor

@zaneselvans Yes, no longer necessary!

@zaneselvans
Copy link
Member

Okay great. Sounds like this is fixed. Hopefully we don't have to deal with any more of this software dependency stuff going forward with the bigger data distributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that are just plain broken. dependencies Pull requests that update a dependency file
Projects
Archived in project
Development

No branches or pull requests

4 participants