[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[HTCondor-users] workaround for HTCondor Python bindings not playing well with Anaconda-installed packages

Sharing some wisdom for the weekend. We heard of a user that is using the Anaconda Python distribution and installs most of their Python libraries (e.g. matplotlib) using the "conda" tool. After installing conda packages in a conda virtual environment, they then install the HTCondor Python bindings using "pip" ("pip install htcondor"), which makes sense as we do not yet distribute a conda package. This leads to an unexpected behavior where if Python imports htcondor before matplotlib, this error is raised:

$ python -c "import htcondor; import matplotlib.pyplot"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/user/anaconda3/envs/condor/lib/python3.7/site-packages/matplotlib/pyplot.py", line 32, in <module>
    import matplotlib.colorbar
  File "/home/user/anaconda3/envs/condor/lib/python3.7/site-packages/matplotlib/path.py", line 17, in <module>
    from . import _path, rcParams
ImportError: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /home/user/anaconda3/envs/condor/lib/python3.7/site-packages/matplotlib/_path.cpython-37m-x86_64-linux-gnu.so)

Per the requirements of building wheels for PyPI to distribute via pip, our htcondor package links against the system libstdc++. However, Anaconda packages may link against a newer, conda-distributed libstdc++, which in the case above, would be located at "/home/user/anaconda3/envs/condor/lib/libstdc++.so.6". The specific libstdc++.so.6 that is loaded and used depends on which library is imported first. So by importing htcondor first, the older, system library is loaded, resulting in incompatibility.

While we are working on a conda package, there is fortunately a workaround. Set the LD_PRELOAD environment variable to force Python to load the newer libstdc++.so.6 from your Anaconda environment. If bash is your shell scripting language of choice, run this after activating your conda environment but before running any Python scripts:

export LD_PRELOAD=$CONDA_PREFIX/lib/libstdc++.so.6

Have a good weekend!

Jason Patton