title: Creation of virtual host through python
body: <p>I have created a python (I m using 2.4) script to automatically create a virtual host in httpd.conf. But when I run it it gives the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "ApaPy2.py", line 2, in ?
      from io import open
  ImportError: No module named io
  </code></pre>
  
  <p>This is my script</p>
  
  <pre><code>import os
  from io import open
  project = raw_input(u'Enter the name of project ')
  domain = raw_input (u'Enter the domain ')
  docroot = raw_input(u'Enter root folder ')
  
  virtualhost=u"""
  &lt;VirtualHost *:80&gt;
      ServerAdmin abhishek.verma@laitkor.com
      DocumentRoot /""" +docroot+ u"""/""" +project+ u"""
      ServerName """ +project+ u""".""" +domain+ u""".com
      ErrorLog logs/""" +project+ u""".com-error_log
      CustomLog logs/""" +project+ u""".com-access_log common
  &lt;/VirtualHost&gt;"""
  
  f = open(u'/etc/httpd/conf/httpd.conf', u'a')
  f.write(virtualhost)
  f.close()
  </code></pre>