0

I am trying to run my Flask application with an Apache server using mod_wsgi, and it has been a bumpy road, to say the least.

It has been suggested that I should try to run my app's .wsgi file using Python to make sure it is working.

This is the contents of the file:

#!/usr/bin/python

activate_this = '/var/www/Giveaway/Giveaway/venv/bin/activate_this.py'
with open(activate_this) as f:
    code = compile(f.read(), "somefile.py", 'exec')
    exec(code)

import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Giveaways/")

from Giveaways import application
application.secret_key = 'Add your secret key'

However, when I run it, I get this error:

ImportError: No module named 'zlib'

And no, I am not using some homebrewed version of Python - I installed Python 3 via apt-get.

Thanks for any help.

Nat Karmios
  • 325
  • 1
  • 4
  • 17

1 Answers1

0

does the contents of somefile.py include the gzip package? in which case you may have to install gzip package via pip or similar

bmbigbang
  • 1,318
  • 1
  • 10
  • 15
  • Pip can't seem to find any package named "gzip". I've tried with both pip and pip3. – Nat Karmios Feb 09 '16 at 14:07
  • have you tried this?: http://stackoverflow.com/questions/6169522/no-module-named-zlib – bmbigbang Feb 09 '16 at 14:36
  • I have seen that answer, and have tried running `sudo apt-get install zlib1g-dev`. It claims that it is already installed, yet I still receive the error with Python. – Nat Karmios Feb 09 '16 at 15:33
  • and do you have multiple python versions installed? zlib should be installed for the one used for your code above – bmbigbang Feb 09 '16 at 15:46
  • Python 2.7 is installed by default, I believe, and I have installed 3.4 via apt-get - those are the only ones installed. Whilst running the program using 2.7 does not give me the error, the syntax of my code is incompatible with Python 2, thus I cannot run using only Python 2. – Nat Karmios Feb 09 '16 at 17:24
  • allright i believe this is the main issue, one potential solution is: http://stackoverflow.com/questions/12344970/building-python-from-source-with-zlib-support beyond this I cannot really help you sorry – bmbigbang Feb 09 '16 at 19:18
  • No such luck, I'm afraid. – Nat Karmios Feb 09 '16 at 22:35