Heroku 返回“导入错误:窗口上没有名为 fcntl 的模块”

Min*_*Ngô 2 python winapi heroku python-3.x facebook-chatbot

我正在 Heroku 上设置应用程序。我在指令中这样做:

图片

在错误 1 ​​中,我在记事本中编码并在命令中运行它:

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})
Run Code Online (Sandbox Code Playgroud)

但它不像指令那样运行

我的命令出现了所以我不知道我该怎么办。

我试着像堆栈帮助

小智 11

我不确定你的问题是否仍然存在,但我现在也在深入研究 heroku,我有一个解决方案。fcntl 模块是一个可用的标准库……仅适用于 Linux!你不会在 Windows 环境下找到它,你显然正在使用它(提示:提到记事本;)

不过不用担心,只需按照官方教程的上一课并调用本地 heroku 服务器,如:

heroku local web -f Procfile.windows
Run Code Online (Sandbox Code Playgroud)

这应该启动你的本地 heroku 服务器没问题,在: http://localhost:5000

希望有帮助!

PS 不要像那样自己运行 views.py。教程严格说要在虚拟环境下做,然后就如计划的那样工作了。