Zotero API Python script doesn't work (sometime)

Hello,

I have a Python script zotero_api.py using Zotero API. This minimalist example connecting to the API is given below (replace with your own id’s). It always works in my Mac terminal. But if I run it through Templater like this:

<% tp.user.zoteroAPI() %>

(with the user function running python zotero_api.py)

then sometime it gives me an error (see below), this is strange!

Steps to reproduce

from pyzotero import zotero

# library_id: https://www.zotero.org/settings/keys
# library_type: 'user' or 'group'
# api_key: https://www.zotero.org/settings/keys/new
zot = zotero.Zotero('library_id', 'library_type', 'api_key')
zot.add_parameters(sort='dateAdded')
items = zot.top()                  

print("worked")

Expected result

worked

Actual result

Templater Error: Error with User Template zoteroAPI_test 
 Error: Command failed: /Users/polisank/opt/anaconda3/bin/python3 _scripts/zotero_api_test.py

    at ChildProcess.exithandler (node:child_process:406:12)
    at ChildProcess.emit (node:events:390:28)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

log_error	@	plugin:templater-obsidian:82
eval	@	plugin:templater-obsidian:105
rejected	@	plugin:templater-obsidian:57
processTicksAndRejections	@	node:internal/process/task_queues:96
Promise.then (async)		
step	@	plugin:templater-obsidian:62
eval	@	plugin:templater-obsidian:63
__async	@	plugin:templater-obsidian:47
errorWrapper	@	plugin:templater-obsidian:98
eval	@	plugin:templater-obsidian:3907
eval	@	plugin:templater-obsidian:63
__async	@	plugin:templater-obsidian:47
overwrite_file_commands	@	plugin:templater-obsidian:3905
overwrite_active_file_commands	@	plugin:templater-obsidian:3902
callback	@	plugin:templater-obsidian:4104
XN	@	app.js:1
e.executeCommand	@	app.js:1
eval	@	plugin:dbfolder:118
o	@	plugin:dbfolder:118
e.onTrigger	@	app.js:1
e.handleKey	@	app.js:1
e.handleKey	@	app.js:1
t.handleKey	@	app.js:1
e.onKeyEvent	@	app.js:1

Environment

  • Operating system: Mac OS Ventura 13.1 (22C65)
  • Debug info:
SYSTEM INFO:
	Obsidian version: v1.1.9
	Installer version: v0.15.9
	Operating system: Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64 22.2.0
	Login status: not logged in
	Insider build toggle: off
	Live preview: on
	Legacy editor: off
	Base theme: dark
	Community theme: none
	Snippets enabled: 3
	Restricted mode: off
	Plugins installed: 50
	Plugins enabled: 37
		1: Obsidian_to_Anki v3.4.1
		2: Calendar v1.5.10
		3: BibNotes Formatter v0.9.12
		4: Media Extended v2.11.1
		5: CSV Table v1.2.0
		6: Toggl Track v0.9.0
		7: Daily Activity v0.4.0
		8: Dialogue v1.0.2
		9: Obsidian42 - Text Transporter v1.0.3
		10: Lumberjack 🪓 🪵 v1.3.0
		11: Workbench v1.6.1
		12: Pandoc Plugin v0.4.1
		13: Citations v0.4.5
		14: Recent Files v1.3.5
		15: Pandoc Reference List v1.2.11
		16: AnkiBridge v0.6.17
		17: Advanced Tables v0.18.1
		18: Periodic Notes v0.0.17
		19: Tag Wrangler v0.5.6
		20: FuzzyTag v1.0.0
		21: Various Complements v7.3.0
		22: Latex Environments v0.3.0
		23: Editor Syntax Highlight v0.1.3
		24: Templater v1.16.0
		25: Convert url to preview (iframe) v0.5.0
		26: Emoji Toolbar v0.3.2
		27: Dataview v0.5.54
		28: Outliner v4.2.1
		29: Advanced URI v1.31.2
		30: Juggl v1.4.0
		31: Auto Link Title v1.3.0
		32: QuickAdd v0.8.0
		33: Open vault in VSCode v1.2.1
		34: Linter v1.10.1
		35: Text Generator v0.1.22
		36: Zotero Integration v2.2.35
		37: DB Folder v3.2.4

RECOMMENDATIONS:
	Custom theme and snippets: for cosmetic issues, please first try updating your theme and disabling your snippets. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community theme and snippets.
	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Up! Any idea?

this is not a place for bug reports about plugins. You should contact templater author.