im in custom app i created, i have in it a folder (x name) inside it y.py
y.py when i call a variable i use frappe.conf.get(“x”)
when i execute this code with python y.py it throws this error for me
RuntimeError: object is not bound
im in custom app i created, i have in it a folder (x name) inside it y.py
y.py when i call a variable i use frappe.conf.get(“x”)
when i execute this code with python y.py it throws this error for me
RuntimeError: object is not bound
Hi, the issue is because frappe.conf requires a Frappe site context to be initialized.
When y.py is executed directly using:
python y.py
it runs as a standalone Python script, so Frappe is not initialized and frappe.conf.get("x") results in:
RuntimeError: object is not bound
The recommended solution is to execute the function through Bench:
bench --site <site-name> execute <app>.<folder>.y.<function_name>
For example, if the structure is:
my_app/
└── my_app/
└── x/
└── y.py
and y.py contains:
import frappe
def test():
value = frappe.conf.get("x")
print(value)
then run:
bench --site <site-name> execute my_app.x.y.test
If python y.py is specifically required, then y.py needs to initialize the Frappe site context first using frappe.init() and frappe.connect() before accessing frappe.conf.
So the issue is not with frappe.conf.get("x"); it is because the script is being executed outside the Frappe/Bench context.