title: Installing mod_wsgi for Python3 on Ubuntu
body: <p>Could anyone give me a clear set of instructions for installing mod_wsgi on Ubuntu for Python 3?</p>
  
  <p>I did get Flask &amp; mod_wsgi successfully using Python3, and for a brief moment felt happy.</p>
  
  <p>...until I looked at Apache's log and realised that I've run into this problem: <a href="https://askubuntu.com/questions/569550/assertionerror-using-apache2-and-libapache2-mod-wsgi-py3-on-ubuntu-14-04-python">https://askubuntu.com/questions/569550/assertionerror-using-apache2-and-libapache2-mod-wsgi-py3-on-ubuntu-14-04-python</a></p>
  
  <p><code>apt-get</code> is installing an out of date version of <code>libapache2-mod-wsgi-py3</code> and this is causing errors in Apache's log.  <em>(Should I report this and if so where?)</em></p>
  
  <p>In the link, the engineer is using <code>pip</code> to install a more up-to-date version.</p>
  
  <p>Interestingly, he appears to be installing it into a virtual Python3 environment. (Would this be any different than using the system <code>pip3</code>?)</p>
  
  <p>Also he uses <code>pip3 install mod_wsgi</code>, but <code>pip3 search mod_wsgi</code> returns:</p>
  
  <p><em>(EDIT: no he doesn't, he uses pip not pip3. Can that be right? Has he got his wires crossed? Isn't pip going to ignore the fact that he is in his py3venv and simply use the system's py2 installation?  But anyway that doesn't resolve the confusion...)</em></p>
  
  <pre><code>mod_wsgi-metrics          - Metrics package for Apache/mod_wsgi.
  cykooz.recipe.pastewsgi   - Buildout recipe to create paste.deploy entry points for mod_wsgi or uwsgi
  mod_wsgi-httpd            - Installer for Apache httpd web server.
  apachemiddleware          - Useful Python middleware for use with mod_wsgi deployments
  tranchitella.recipe.wsgi  - Buildout recipe to create paste.deploy entry points for mod_wsgi
  mod_wsgi                  - Installer for Apache/mod_wsgi.
  </code></pre>
  
  <p>So what is <code>mod_wsgi-httpd</code>? And is it certain this isn't the one I want?</p>
  
  <p>Finally, can anyone provide a link to installing mod_wsgi from source?</p>
  
  <p>EDIT: I don't get why the engineer is using <code>pip install mod_wsgi</code> rather than <code>pip3 ...</code>. Surely that can't be right?  But if I do use pip3, I get:</p>
  
  <pre><code>pi@PiDroplet:~$ cd web/piFlask
  
  pi@PiDroplet:~/web/piFlask$ source ./venv3/bin/activate
  (venv3)
  pi@PiDroplet:~/web/piFlask$ pip3 install mod_wsgi
  Downloading/unpacking mod-wsgi
    Downloading mod_wsgi-4.4.12.tar.gz (991kB): 991kB downloaded
    Running setup.py (path:/home/pi/web/piFlask/venv3/build/mod-wsgi/setup.py) egg_info for package mod-wsgi
      Traceback (most recent call last):
        File "&lt;string&gt;", line 17, in &lt;module&gt;
        File "/home/pi/web/piFlask/venv3/build/mod-wsgi/setup.py", line 141, in &lt;module&gt;
          'missing Apache httpd server packages.' % APXS)
      RuntimeError: The 'apxs' command appears not to be installed or is not executable. Please check the list of prerequisites in the documentation for this package and install any missing Apache httpd server packages.
      Complete output from command python setup.py egg_info:
      Traceback (most recent call last):
  
    File "&lt;string&gt;", line 17, in &lt;module&gt;
  
    File "/home/pi/web/piFlask/venv3/build/mod-wsgi/setup.py", line 141, in &lt;module&gt;
  
      'missing Apache httpd server packages.' % APXS)
  
  RuntimeError: The 'apxs' command appears not to be installed or is not executable. Please check the list of prerequisites in the documentation for this package and install any missing Apache httpd server packages.
  
  ----------------------------------------
  Cleaning up...
  Command python setup.py egg_info failed with error code 1 in /home/pi/web/piFlask/venv3/build/mod-wsgi
  Storing debug log for failure in /home/pi/.pip/pip.log
  </code></pre>
  
  <p>And now I try <code>pip3 install mod_wsgi-httpd</code>, it takes about five minutes to compile:</p>
  
  <pre><code>(venv3)
  pi@PiDroplet:~/web/piFlask$ pip3 install mod_wsgi-httpd
  Downloading/unpacking mod-wsgi-httpd
    Downloading mod_wsgi-httpd-2.4.12.5.tar.gz
    Running setup.py (path:/home/pi/web/piFlask/venv3/build/mod-wsgi-httpd/setup.py) egg_info for package mod-wsgi-httpd
      apr-1.5.2/
      apr-1.5.2/config.layout
      apr-1.5.2/build.conf
      apr-1.5.2/emacs-mode
      :
  </code></pre>
  
  <p>So now I'm worried I've got a second Apache sitting in my Py3 virtualenv.</p>
  
  <p>However that does get rid of the error; <code>pip3 install mod_wsgi</code> now completes successfully.</p>
  
  <p>EDIT: but now I have come completely unstuck trying to follow his instructions: I don't have a <code>/etc/apache2/mods-available/wsgi_express.load</code>, and if he is suggesting making it, then for a start this seems arbitrary, and secondly the text he suggests putting in it, i.e. <code>LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi-py34.cpython-34m.so</code> -- this file doesn't exist on my system.</p>
  
  <p>I do have <code>/etc/apache2/mods-available/wsgi.load</code></p>
  
  <p>Drowning in technology again, can someone throw me a line?</p>