pyd
pyd copied to clipboard
Doc: add workaround AttributeError: module 'sys' has no attribute 'argv'
I tried some code like this:
py_init();
po = py_eval("MyClass()", "mymodule"); // mymodule.py exists and is on PYTHONPATH
When I run it, it errors out:
pyd.exception.PythonException@/home//.dub/packages/pyd-0.13.1/pyd/infrastructure/pyd/pydobject.d(59):
AttributeError: module 'sys' has no attribute 'argv'
----------------
??:? [0x555555d88025]
??:? [0x555555db0326]
??:? [0x555555d93e9d]
exception.d:46 [0x555555c299d6]
pydobject.d:59 [0x555555c2e10c]
embedded.d:54 [0x555555c2956e]
/home//.dub/packages/pyd-0.13.1/pyd/infrastructure/pyd/embedded.d:235 [0x55555575b92e]
my.d:35 [0x555555757c59]
...
I googled a bit, and find this maybe related:
https://github.com/googleapis/oauth2client/issues/642
and the suggestion is:
Workaround is to start embedded script with:
import sys
if not hasattr(sys, 'argv'):
sys.argv = ['']
tried to add in mymodule.py at the top, and it worked.
Thanks.
I tried to add in mymodule.py, it seems working.
But I think this info should be added to the pyd doc README.md
This is curious. I am not seeing this behavior on fedora/python38. What are you running on?
Ubuntu / python3.6