Azure App Service Linux - Python - XGBoost Library ( Could Not Be Loaded

1 minute read | By Toan Nguyen

If you’re attempting to run XGBoost on Azure App Service on Linux, you may receive the following error.

Traceback (most recent call last):
  File "", line 1, in <module>
    import xgboost as xgb
  File "/opt/python/3.7.5/lib/python3.7/site-packages/xgboost/", line 11, in <module>
    from .core import DMatrix, Booster
  File "/opt/python/3.7.5/lib/python3.7/site-packages/xgboost/", line 161, in <module>
    _LIB = _load_lib()
  File "/opt/python/3.7.5/lib/python3.7/site-packages/xgboost/", line 152, in _load_lib
    'Error message(s): {}\n'.format(os_error_list))
xgboost.core.XGBoostError: XGBoost Library ( could not be loaded.
Likely causes:
  * OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, for UNIX-like OSes)
  * You are running 32-bit Python on a 64-bit OS
Error message(s): [' cannot open shared object file: No such file or directory', ' cannot open shared object file: No such file or directory']

GCC will need to be installed using a custom startup script which is covered in my other article Azure App Service Linux - Custom Startup Script for Nodejs & Python.

Modifying the Startup Script

Instead of using the example provided in step #3, use the following to install GCC.

apt-get update && apt-get install -y gcc

Saving the Changes

In the Azure Portal configurations, add “/home/” as the Startup Command and restart the site.