Missing wsgiref==0.1.2 when i "pip freeze"


For whatever reason at the part in the book where you pip freeze, the list of libraries did not include wsgiref==0.1.2 which I believe was causing my app to crash when trying to use heroku for hosting. Any ideas on how to resolve this? Here is the output:

(venv)Ryans-MacBook-Air:hellowebapp ryandodds$ pip freeze
(venv)Ryans-MacBook-Air:hellowebapp ryandodds$


I am SO sorry about the delayed response — there was an error in my emailing and I wasn’t getting notices of when people posted to the forum. Blergh.

Did you manage to get this fixed in the last month (bleeergh)? Happy to dig into it now if you’re still stuck.


I am having the same problem with deploying to Heroku and I also don’t have wsgiref come up with I run pip freeze. Looks like Ryan bailed on this topic but I’ll take some help :)

I tried to directly install wsfiref and here is what I get:

(venv) Dans-MacBook-Pro:myhelloapp danlabelle$ pip install wsgiref
Requirement already satisfied: wsgiref in /usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7

But when I pip freeze, it is not there as a requirement:

(venv) Dans-MacBook-Pro:myhelloapp danlabelle$ pip freeze


Also, reviewing the GitHub files online I find a difference between the book and the code on GitHub.

online it has:
import os

The book version doesn’t have the “_production” part.


wsgiref should be installed automatically with either Django or Python (forgot which, will look it up), which is why it’s not needed in the requirements file — when you deploy to Heroku, it’ll install the packages listed and their dependencies automatically, which wsgiref is a part of.

Are you happening to be using Python 3? Seems like there is a difference with wsgiref and Python 3 and I’m wondering if this is where the issue is rooted.

Huh. Where did you buy your book? Amazon, hellowebapp.com, or leanpub.com?


Thanks for the reply!

I am using Python 2.7. I bought my book through Amazon.

As for Heroku, the problem seems to be that it isn’t recognizing my app as a python app. I’m guessing it is missing something in the requirements.txt file that it checks. I have also used the buildpack:set command to force Heroku to try and use the python buildpack.

Why are we using WSGI instead of what Heroku wants us to use? Sorry, forgot the name but it begins with a G.


We’re using WSGI because it’s the primary deployment platform for Django: https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/

Oh, did you check which part of the chapter this is referencing? Because you start with .settings but later in the chapter it changes once you create settings_production.py:

Can you paste me in the exact error you’re getting with Heroku?


I now see when in the process I should be creating settings_production.py. I hadn’t gotten that far yet because I am getting an error from Heroku at the initial “git push heroku master” command (page 105). Looks like you make that change after the initial code push to Heroku. Sorry for the confusion. I’m hitting the following error on the initial git push to heroku:

(venv) Dans-MacBook-Pro:myhelloapp danlabelle$ git push heroku master
Counting objects: 9192, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8234/8234), done.
Writing objects: 100% (9192/9192), 9.71 MiB | 1.44 MiB/s, done.
Total 9192 (delta 4229), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: -----> Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote: More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:  !     Push failed
remote: Verifying deploy...
remote: !	Push rejected to pure-spire-14731.
To https://git.heroku.com/pure-spire-14731.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pure-spire-14731.git'
(venv) Dans-MacBook-Pro:myhelloapp danlabelle$ 

I’ve done everything I can with the buildpack to try and get it to work (cleared it, set it to python, etc.) My Heroku dashboard says that it’s set to python.

Also, here are the contents of my requirements.txt file as generated from pip freeze:


Hey There,

So I not smart…

Just realized that a few files were not getting committed to git including the requirements.txt file. So, no wonder Heroku didn’t see it as a python app facepalm. I’ve been using "git commit -a -m “message here”’ but it wasn’t uploading all the files for some reason. I used “git add -A && git commit -m “Your Message”” which I guess uploads EVERYTHING and it worked.

Sorry for the wild goose chase. I seriously need to spend some more time getting familiar with Git for sure. Thanks for being so responsive and helpful! Love the books. Moving on to intermediate concepts next.