Frappe.connect error

I am trying to use a Python file to change records on ERPNext but am not able to connect to the currentsite. As advised on this link below :

I used frappe.init() and frappe.connect() but I get this error traceback (local python environment is activated)

Traceback (most recent call last):
  File "apps/erpnext/erpnext/stock/doctype/serial_no/", line 103, in <module>
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 158, in init
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 853, in setup_module_map
    for app in get_all_apps(True):
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 737, in get_all_apps
    apps = get_file_items(os.path.join(sites_path, "apps.txt"), raise_not_found=True)
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 869, in get_file_items
    content = read_file(path, raise_not_found=raise_not_found)
  File "/home/user/frappe-bench/apps/frappe/frappe/", line 891, in read_file
    raise IOError("{} Not Found".format(path))
IOError: ./apps.txt Not Found

Here is how I have used these two here:

def execute():
    Interface for executing patch
    data = []
    data = get_data(warehouse_script)

I used the entire path because previously when I would mention site1.local it just wouldn’t run and throw an error that site1.local does not exist. What am I doing wrong here ?

EDIT : I was able to run the script by navigating to the sites folder and apps.txt was present there.

It says apps.txt not found… Do you have that file ?

apps.txt is found in frappe-bench/sites so the file was able to execute when ran from this folder. An attempt to run this file via bench run-tests was done, but specifying the doctype and test did not work because it kept on running the test for the entire app.

My preferred way of making changes to the database is using
bench console

1 Like

I think this file can be imported in bench console and then I can run the functions I want. I’ll try this out.

1 Like

Well this thing about run-tests happens to me all the time.

So this is how i do it… instead of using --app or --test option, i use --module option.

$bench run-tests --module

So that it does not run other tests. It gets annoying to see that unwanted test data appearing in desk and leaving us wondering where this test data came from… :slight_smile:

I believe there should be better option than --module as well… but shit worked for me as of now…



Yes files should be imported too. Let us know how you did if you could here…