Heroku EOFError仅适用于两行Python代码 [英] Heroku EOFError for only two line python code

查看:101
本文介绍了Heroku EOFError仅适用于两行Python代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试将Python程序部署到Heroku.

我的python程序是

name=input("What is your name?: ");
print("Nice to meet you", name)  

https://shielded-gorge-83102.herokuapp.com/

Application error 
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail 

在执行日志命令时:

(intro) D:\heroku>heroku logs
    2018-12-12T13:43:55.763708+00:00 app[api]: Release v2 created by user m.naufil1@gmail.com
    2018-12-12T13:43:55.600014+00:00 app[api]: Initial release by user m.naufil1@gmail.com
    2018-12-12T13:43:55.600014+00:00 app[api]: Release v1 created by user m.naufil1@gmail.com
    2018-12-12T13:43:55.763708+00:00 app[api]: Enable Logplex by user m.naufil1@gmail.com
    2018-12-12T13:44:09.000000+00:00 app[api]: Build started by user m.naufil1@gmail.com
    2018-12-12T13:44:33.155579+00:00 app[api]: Release v3 created by user m.naufil1@gmail.com
    2018-12-12T13:44:33.172663+00:00 app[api]: Scaled to web@1:Free by user m.naufil1@gmail.com
    2018-12-12T13:44:36.735728+00:00 heroku[web.1]: Starting process with command `python script.py`
    2018-12-12T13:44:38.669558+00:00 heroku[web.1]: Process exited with status 1
    2018-12-12T13:44:38.605013+00:00 app[web.1]: What is your name?: Traceback (most recent call last):
    2018-12-12T13:44:38.605042+00:00 app[web.1]: File "script.py", line 8, in <module>
    2018-12-12T13:44:38.605143+00:00 app[web.1]: name=input("What is your name?: ");
    2018-12-12T13:44:38.605148+00:00 app[web.1]: EOFError: EOF when reading a line
    2018-12-12T13:44:38.834792+00:00 heroku[web.1]: State changed from starting to crashed
    2018-12-12T13:44:38.836807+00:00 heroku[web.1]: State changed from crashed to starting
    2018-12-12T13:44:42.997678+00:00 heroku[web.1]: Starting process with command `python script.py`
    2018-12-12T13:44:45.507921+00:00 heroku[web.1]: State changed from starting to crashed
    2018-12-12T13:44:45.418724+00:00 heroku[web.1]: Process exited with status 1
    2018-12-12T13:44:45.349072+00:00 app[web.1]: What is your name?: Traceback (most recent call last):
    2018-12-12T13:44:45.357936+00:00 app[web.1]: File "script.py", line 8, in <module>
    2018-12-12T13:44:45.360501+00:00 app[web.1]: name=input("What is your name?: ");
    2018-12-12T13:44:45.360593+00:00 app[web.1]: EOFError: EOF when reading a line
    2018-12-12T13:45:01.410054+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shielded-gorge-83102.herokuapp.com request_id=95386b8c-f2e6-4d0f-8dcb-6355cf75da60 fwd="39.50.204.180" dyno= connect= service= status=503 bytes= protocol=https

我阅读了这篇文章:应用程序在Heroku Pyphon应用程序上崩溃

表示you cant use input command here.那么这是因为它是一个Web应用程序,并且打印命令无法在浏览器上运行吗?请告诉我如何在不输入信息的情况下运行该程序.

因此,如果我们在这里需要一点HTML,我也知道使用HTML.因此,请帮助我使用python运行该程序.

解决方案

您仍然可以拥有input,但是方式有所不同.查看此将数据从文本框发送到Flask吗?

然后,一旦您有一个简单的应用程序,请按照本教程进行操作,以使其进行部署 https ://devcenter.heroku.com/articles/getting-started-with-python

您很可能已经知道大多数步骤.同样,并非所有都是强制性的.

Its my first attempt to deploy a python program to Heroku.

My python program was

name=input("What is your name?: ");
print("Nice to meet you", name)  

and https://shielded-gorge-83102.herokuapp.com/says

Application error 
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command
heroku logs --tail 

On executing logs command:

(intro) D:\heroku>heroku logs
    2018-12-12T13:43:55.763708+00:00 app[api]: Release v2 created by user m.naufil1@gmail.com
    2018-12-12T13:43:55.600014+00:00 app[api]: Initial release by user m.naufil1@gmail.com
    2018-12-12T13:43:55.600014+00:00 app[api]: Release v1 created by user m.naufil1@gmail.com
    2018-12-12T13:43:55.763708+00:00 app[api]: Enable Logplex by user m.naufil1@gmail.com
    2018-12-12T13:44:09.000000+00:00 app[api]: Build started by user m.naufil1@gmail.com
    2018-12-12T13:44:33.155579+00:00 app[api]: Release v3 created by user m.naufil1@gmail.com
    2018-12-12T13:44:33.172663+00:00 app[api]: Scaled to web@1:Free by user m.naufil1@gmail.com
    2018-12-12T13:44:36.735728+00:00 heroku[web.1]: Starting process with command `python script.py`
    2018-12-12T13:44:38.669558+00:00 heroku[web.1]: Process exited with status 1
    2018-12-12T13:44:38.605013+00:00 app[web.1]: What is your name?: Traceback (most recent call last):
    2018-12-12T13:44:38.605042+00:00 app[web.1]: File "script.py", line 8, in <module>
    2018-12-12T13:44:38.605143+00:00 app[web.1]: name=input("What is your name?: ");
    2018-12-12T13:44:38.605148+00:00 app[web.1]: EOFError: EOF when reading a line
    2018-12-12T13:44:38.834792+00:00 heroku[web.1]: State changed from starting to crashed
    2018-12-12T13:44:38.836807+00:00 heroku[web.1]: State changed from crashed to starting
    2018-12-12T13:44:42.997678+00:00 heroku[web.1]: Starting process with command `python script.py`
    2018-12-12T13:44:45.507921+00:00 heroku[web.1]: State changed from starting to crashed
    2018-12-12T13:44:45.418724+00:00 heroku[web.1]: Process exited with status 1
    2018-12-12T13:44:45.349072+00:00 app[web.1]: What is your name?: Traceback (most recent call last):
    2018-12-12T13:44:45.357936+00:00 app[web.1]: File "script.py", line 8, in <module>
    2018-12-12T13:44:45.360501+00:00 app[web.1]: name=input("What is your name?: ");
    2018-12-12T13:44:45.360593+00:00 app[web.1]: EOFError: EOF when reading a line
    2018-12-12T13:45:01.410054+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shielded-gorge-83102.herokuapp.com request_id=95386b8c-f2e6-4d0f-8dcb-6355cf75da60 fwd="39.50.204.180" dyno= connect= service= status=503 bytes= protocol=https

I read this post: App crashing on Heroku Pyphon application

and it says you cant use input command here. So is this because it is a web app and print command cant run on browser? Please tell me how to run this program without taking input.

So, if we need a bit HTML here, I also know working with HTML. So please help me with running this program using python.

解决方案

You can still have input, but in a bit different way. Check out this Send data from a textbox into Flask?

Then once you have a simple app follow this tutorial to get it deployed https://devcenter.heroku.com/articles/getting-started-with-python

Most likely you know most of the steps already. Also not all of them are mandatory.

这篇关于Heroku EOFError仅适用于两行Python代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆