When a Python app runs out side of Bluemix but fails when run in Bluemix

Question:

This is a question that I am going to answer myself, as I have seen it countless times and it really should count as a FAQ.

Say you have created a Flask or a Django application and it is working in both your testing envrionments – outside of bluemix and inside of bluemix.
Then you make a change, or incorporate a new pip import and now altough your application still runs in your own local environment, but it fails when you push it to Bluemix.

You might see something like:

OUT Starting app instance (index 0) with guid .... 
ERR Instance (index 0) failed to start accepting connections
Asked By: chughts

||

Answers:

If it is working in your local environment then the problem lies in porting to Bluemix. If it was working before you made your changes then its something that you have added. Assuming of course that you have made no changes to your Procfile, and the way the program launches.

This points at differences in the python runtime between your local environment and Bluemix. What will be happening is that a code structure (something like the way you perform an iteration) is supported in the python version you are running locally, but not supported by the python version you are using on bluemix.

If you don’t have a runtime.txt file then create one. Set its contents it to the version of python that you have on your local environment (eg. python-3.4.3)

Check on the python runtime on Bluemix, to see which versions of python are supported. If your version isn’t then you will need to explicitly set the buildpack in your manifest.yml file. eg. buildpack: https://github.com/cloudfoundry/python-buildpack#v1.5.1

I normally do this anyway to insulate my apps from changes to the default Bluemix runtimes.

If none of this helps then you have created a coding error in code that is only executed on Bluemix.

Answered By: chughts
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.