Ansible - "NameError: name 'urllib2' is not defined"
<p>Getting this below error while trying to run ansible(version >2) with python 3.5.2</p>

<p>I have looked into the github issues terming it as resolved, but can't sort out what needs to be done. <a href="https://github.com/ansible/ansible/issues/16013" rel="nofollow">https://github.com/ansible/ansible/issues/16013</a></p>

<p>How to resolve this?</p>

<pre><code>virtual@xxxxxxxxxx:~/ansible-spike&gt; ansible all -m ping -vvv
    Using /home/virtual/ansible-spike/ansible.cfg as config file
    ERROR! Unexpected Exception: name 'urllib2' is not defined
    the full traceback was:

    Traceback (most recent call last):
      File "/home/virtual/.pyenv/versions/3.5.2/bin/ansible", line 92, in &lt;module&gt;
        exit_code = cli.run()
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/site-packages/ansible/cli/adhoc.py", line 193, in run
        result = self._tqm.run(play)
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/site-packages/ansible/executor/task_queue_manager.py", line 202, in run
        self.load_callbacks()
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/site-packages/ansible/executor/task_queue_manager.py", line 171, in load_callbacks
        for callback_plugin in callback_loader.all(class_only=True):
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/site-packages/ansible/plugins/__init__.py", line 368, in all
        self._module_cache[path] = self._load_module_source(name, path)
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/site-packages/ansible/plugins/__init__.py", line 319, in _load_module_source
        module = imp.load_source(name, path, module_file)
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/imp.py", line 172, in load_source
        module = _load(spec)
      File "&lt;frozen importlib._bootstrap&gt;", line 693, in _load
      File "&lt;frozen importlib._bootstrap&gt;", line 673, in _load_unlocked
      File "&lt;frozen importlib._bootstrap_external&gt;", line 665, in exec_module
      File "&lt;frozen importlib._bootstrap&gt;", line 222, in _call_with_frames_removed
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/site-packages/ansible/plugins/callback/hipchat.py", line 32, in &lt;module&gt;
        from ansible.module_utils.urls import open_url
      File "/home/virtual/.pyenv/versions/3.5.2/lib/python3.5/site-packages/ansible/module_utils/urls.py", line 330, in &lt;module&gt;
        if hasattr(httplib, 'HTTPSConnection') and hasattr(urllib2, 'HTTPSHandler'):
    NameError: name 'urllib2' is not defined
</code></pre>