diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index d87f18cbd3b..f0275e86874 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -2022,6 +2022,8 @@ class AnsibleModule(object): if not x.endswith('/ansible_modlib.zip') \ and not x.endswith('/debug_dir')] os.environ['PYTHONPATH'] = ':'.join(pypaths) + if not os.environ['PYTHONPATH']: + del os.environ['PYTHONPATH'] # create a printable version of the command for use # in reporting later, which strips out things like