Error loading python script "module sys has no attribute 'argv'"

Why load python script is failing with error "Sys has no argument 'argv'"?

When the library is used with embedded Python (e.g. Postgres extension written in C calling Python, like Multicorn), sys.argv is not defined, which makes the library misbehave.

Workaround : Assign a empty string to the sys.argv value as given below while importing the same and it should work.

import sys

if not hasattr(sys, 'argv'):
    sys.argv  = ['']