Search code examples
pythonubuntucondaoserror

how to solve cannot allocate memory in static TLS block error for python packages


I am using ubuntu 20.04 and conda 4.8.3. I have installed a package in one of my environments using pip (pip install --force-reinstall --no-cache-dir gmsh-dev) but when I try to import the package in a jupyter notebook, I face the following error:

OSError: /home/alid/miniconda3/envs/new_env/lib/python3.9/site-packages/gmsh-git-Linux64-sdk/lib/libgmsh.so: cannot allocate memory in static TLS block

I have no idea what is my problem and do appreciate any help.


Solution

  • Based on how others solved similar problems, try adding it to LD_PRELOAD.

    ## set the env var for "new_env" environment
    conda env config vars set -n new_env LD_PRELOAD='/home/alid/miniconda3/envs/new_env/lib/python3.9/site-packages/gmsh-git-Linux64-sdk/lib/libgmsh.so'
    
    ## test importing
    conda run -n new_env python -c "import gmsh"
    

    See the documentation on managing environment variables in Conda envs.