8

I'm trying to run hello.py from this Python Heroku tutorial. My problems began after running this command: foreman start. I got the following error even though I installed the Heroku Toolbelt:

foreman is not recognized as an internal or external command, operable program or batch file

So I added the location of the foreman file (version 0.63.0) to my path:

C:\Program Files (x86)\Heroku\ruby-1.9.2\bin

and restarted the command prompt and reran foreman start. Now, I'm getting this error:

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Users\me\Desktop\Code\heroku_python_app>venv\Scripts\activate
(venv) C:\Users\me\Desktop\Code\heroku_python_app>foreman start
Bad file descriptor
C:/Program Files (x86)/Heroku/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/foreman-0.63.0
/lib/foreman/engine.rb:372:in `read_nonblock'
C:/Program Files (x86)/Heroku/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/foreman-0.63.0
/lib/foreman/engine.rb:372:in `block (2 levels) in watch_for_output'
C:/Program Files (x86)/Heroku/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/foreman-0.63.0
/lib/foreman/engine.rb:368:in `loop'
C:/Program Files (x86)/Heroku/ruby-1.9.2/lib/ruby/gems/1.9.1/gems/foreman-0.63.0
/lib/foreman/engine.rb:368:in `block in watch_for_output'
12:57:38 web.1  | exited with code 1
12:57:38 system | sending SIGKILL to all processes

(venv) C:\Users\me\Desktop\Code\heroku_python_app>

hello.py

import os
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello World'

Procfile

web: gunicorn hello:app

EDIT 1

After reading this answer, I did the following:

gem uninstall foreman   
gem install foreman -v 0.61.0

However, when I reran foreman start I'm getting this error now

(venv) C:\Users\me\Desktop\Code\heroku_python_app>foreman start
14:13:20 web.1  | started with pid 252
14:13:20 web.1  | exited with code 1
14:13:20 system | sending SIGKILL to all processes
14:13:20        | Traceback (most recent call last):
14:13:20        |   File "C:\Users\me\Desktop\Code\heroku_python_app\venv\Scri
pts\gunicorn-script.py", line 9, in <module>

(venv) C:\Users\me\Desktop\Code\heroku_python_app>

Any assistance will be really appreciated. Thanks in advance.

Community
  • 1
  • 1
Anthony
  • 3,990
  • 23
  • 68
  • 94
  • I'm beginning to realize that Heroku is not a popular topic on SO at all! It looks so cool and interesting to me, not sure why no one else seems to think so. – Anthony Jun 12 '13 at 11:28
  • 1
    Can you run the web command from your Procfile without Foreman? – georgebrock Jun 12 '13 at 22:31
  • +1 Thanks for your reply @georgebrock . How do I run the web command from the Procfile without Foreman? The tutorial does not cover this. Also, does Gunicorn work on Windows? Because when I went to the Gunicorn site, it said it was for Unix. – Anthony Jun 14 '13 at 11:48
  • 1
    Your Procfile should contain a line like `web: something`, just type the `something` part at the command line and see what happens. – georgebrock Jun 14 '13 at 11:57
  • +1, in the Procfile I had: `web: gunicorn hello:app`. In the command prompt, I entered `gunicorn hello:app` but I got this error message: `gunicorn` is not recognized as an internal or external command.... " I also tried `gunicorn hello` and I got a long Traceback with the last line saying: `ImportError: No module named fcnt1`. – Anthony Jun 14 '13 at 12:10
  • @georgebrock I downloaded gunicorn again `pip install Flask gunicorn` to see where it would be saved... it saved here: `myapp/venv/Lib/site-packages` . – Anthony Jun 14 '13 at 12:27
  • 1
    Did you find a solution? I have the exact same problem. – RexE Aug 21 '13 at 18:50
  • 2
    +1 @RexE From my understanding, this problem was caused by the fact that Gunicorn is not supported on Windows (I was using Windows XP) see their website (http://gunicorn.org/). However, I am going to give it another try with Linux CentOS and will report back to you. FYI, I also tried running Ubuntu in a virtual machine however, my system was just too slow for the VM to work properly. So I dual booted my machine with CentOS and I'm going to retry shortly. Another alternative is to create an Amazon EC2 instance and select one of their Linux AMIs and try it there as well. – Anthony Aug 22 '13 at 22:44
  • 1
    I got it working! It started working after I created an SSH key, I believe. – RexE Aug 23 '13 at 16:22
  • +1 Creating an SSH key resolved your `bad file descriptor` error? – Anthony Aug 23 '13 at 16:34

1 Answers1

6

I fixed this problem by running the following:

gem uninstall foreman
gem install foreman -v 0.61.0 [EDIT]

As mentioned here.

Community
  • 1
  • 1
kfrncs
  • 433
  • 3
  • 15