Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: add workaround AttributeError: module 'sys' has no attribute 'argv' #141

Open
mw66 opened this issue Oct 29, 2020 · 3 comments
Open

Comments

@mw66
Copy link
Contributor

mw66 commented Oct 29, 2020

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:

googleapis/oauth2client#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.

@mw66
Copy link
Contributor Author

mw66 commented Oct 29, 2020

I tried to add in mymodule.py, it seems working.

But I think this info should be added to the pyd doc README.md

@mw66 mw66 changed the title AttributeError: module 'sys' has no attribute 'argv' Doc: add workaround AttributeError: module 'sys' has no attribute 'argv' Oct 29, 2020
@ariovistus
Copy link
Owner

This is curious. I am not seeing this behavior on fedora/python38. What are you running on?

@mw66
Copy link
Contributor Author

mw66 commented Dec 20, 2020

Ubuntu / python3.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants