Author pgacv2
Recipients docs@python, pgacv2
Date 2018-01-16.19:46:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Embedded Python interpreters, such as Boost.Python, do not have sys.argv available. (sys itself works fine.) This causes the interpreter to crash with the following exception when you try to access argv:

    AttributeError: 'module' object has no attribute 'argv'

I'm not sure how closely related this is to #15577 or PEP 432. A simple workaround is to manually assign a list with an empty string to argv, as suggested by However, the documentation for the sys module makes no mention of this special case for argv, and the line at the top that says "It is always available" can easily be interpreted to mean that *all* of sys's attributes will always be available. I suggest adding the following to the documentation for sys.argv:


Since `argv` contains the list of **command line** arguments passed to the Python interpreter, `argv` is not available within embedded interpreters, and scripts that run in embedded environments will raise an `AttributeError` when they attempt to access `argv`. As a workaround, assign a list with an empty string manually:
import sys

if not hasattr(sys, 'argv'):
    sys.argv  = ['']
Date User Action Args
2018-01-16 19:46:28pgacv2setrecipients: + pgacv2, docs@python
2018-01-16 19:46:28pgacv2setmessageid: <>
2018-01-16 19:46:28pgacv2linkissue32573 messages
2018-01-16 19:46:28pgacv2create