Load Python Module correctly

luckydog xf luckydogxf at gmail.com
Mon Mar 25 04:32:28 CET 2019

Hi, list,

 I want to write my own python code,  I added below lines.

# /etc/raddb/mods-enabled/python

        python_path =  "/usr/lib64/python2.7/"

        module = example

in /usr/lib64/python2.7/example.py, I imported required modules.
import radiusd
import requests
import json
... ... some other code ......

And radiusd -X raised an error:

python_function_load - Module 'example' not found
<type 'exceptions.ImportError'> (No module named requests)
python_function_load - Failed to import python function
/etc/raddb/mods-enabled/python[9]: Instantiation failed for module "python"

Acutally, * requests * and * json * are both available, see

# python
...... # remove unless lines ###
>>> import radiusd
>>> import requests
>>> import json

So what's the right way to implement this? Thanks.

More information about the Freeradius-Users mailing list