Heroku returns "ImportError: No module named fcntl on window"

4.7k views Asked by At

I'm setting app on Heroku. I do in instruction like so:

Image

In error 1, I code in Notepad and run it in command:

import requests
from django.shortcuts import render
from django.http import HttpResponse

from .models import Greeting

# Create your views here.
def index(request):
     r = requests.get('http://httpbin.org/status/418')
     print(r.text)
     return HttpResponse('<pre>' + r.text + '</pre>')



def db(request):

    greeting = Greeting()
    greeting.save()

    greetings = Greeting.objects.all()

    return render(request, 'db.html', {'greetings': greetings})

But it dont run like instruction

My command appeard that so i dont know what can I should do.

I was try like Stack help

2

There are 2 answers

0
AudioBubble On

Your code above is correct. Please install requests on your (master) as follows:

  1. (python-getting-started) Ja ~/python-getting-started (master) pipenv install requests
  2. then run heroku local
0
Kuba Siekierzyński On

I am not sure if your question is still on, but I'm digging into heroku right now, too and I have a solution for you. The fcntl module is a standard library available... on Linux only! You won't find it under Windows environment, which you are apparently using (hint: Notepad mentioned ;)

But no worries, just follow the official tutorial's previous lesson and invoke the local heroku server like:

heroku local web -f Procfile.windows

This should start your local heroku server no problem, under: http://localhost:5000

Hope that helps!

P.S. Don't run views.py on its own like that. The tutorial strictly says to do it under the virtual environment, then it works, like planned.