title: python 2.7: AddressValueError: ip does not appear to be an IPv4 or IPv6 network
body: <p>I am just running the example on: <a href="https://docs.python.org/3/howto/ipaddress.html#ipaddress-howto" rel="nofollow noreferrer">https://docs.python.org/3/howto/ipaddress.html#ipaddress-howto</a></p>
  
  <p>However, in the following example:</p>
  
  <pre><code>import ipaddress
  
  net4 = ipaddress.ip_network("192.0.2.0/24")
  for x in net4.hosts():
      print(x)
  </code></pre>
  
  <p>I got the following error:</p>
  
  <pre><code>AddressValueErrorTraceback (most recent call last)
  &lt;ipython-input-18-256ed42a96d9&gt; in &lt;module&gt;()
        1 import ipaddress
        2 
  ----&gt; 3 net4 = ipaddress.ip_network("192.0.2.0/24")
        4 for x in net4.hosts():
        5     print(x)
  
  /usr/local/lib/python2.7/dist-packages/ipaddress.pyc in ip_network(address, strict)
      197             '%r does not appear to be an IPv4 or IPv6 network. '
      198             'Did you pass in a bytes (str in Python 2) instead of'
  --&gt; 199             ' a unicode object?' % address)
      200 
      201     raise ValueError('%r does not appear to be an IPv4 or IPv6 network' %
  
  AddressValueError: '192.0.2.0/24' does not appear to be an IPv4 or IPv6 network. Did you pass in a bytes (str in Python 2) instead of a unicode object?
  </code></pre>
  
  <p>Did I miss anything here (I am using python 2.7)? Thanks!</p>