GLIBCXX not found when using reticulate, unless LD_LIBRARY_PATH is set

I am using conda version 22.9.0, conda-build version 3.22.0, python version 3.9.13.final.0 on Amazon Linux 2. I am using R version 3.4.3 and have installed the reticulate package version 1.28. If I load reticulate and try to import pandas, it gives an error:

ImportError: /lib64/libstdc++.so.6: version GLIBCXX_3.4.29’ not found (required by /home/hadoop/anaconda3/lib/python3.9/site-packages/pandas/_libs/window/aggregations.cpython-39-x86_64-linux-gnu.so)`

this is because on my system, /usr/lib64/libstdc++.so.6 does not support anything beyond GLIBCXX_3.4.24. I know one way to solve this is to set

LD_LIBRARY_PATH=/home/hadoop/anaconda3/lib

but I’m wondering if there is a more standard approach? I also wonder if this is evidence of a mis-configuration somewhere in the toolchain.

You need to update pandas.

pip install -U pandas