0

I am trying to push a flask app (Python 3.5) to Cloud Foundry (CF). The application takes a POST request (text file) and returns a message. It works locally (tested via Postman). However, when attempting to push it to CF, it gives the error -

ImportError: No module named queue

Here is my code which contains queue.

import queue as Queue
self._batch_queue = Queue.Queue(self.BATCH_QUEUE_MAX)
self._example_queue = Queue.Queue(self.BATCH_QUEUE_MAX * self._hps.batch_size)

I've tried the solutions suggested here, but neither of these solve my problem. I think the issue is with the Python in CF not having queue package. (I could be wrong).

Anyone ideas on how to go about solving this will be very appreciated. Thanks in advance!

KRW4
  • 67
  • 2
  • 10
  • 4
    Wrong Python version? I would expect this error on Python 2. – Klaus D. Jun 12 '18 at 08:44
  • Yeah. Most probably you trying to run python-3 program on python-2. Read: https://docs.python.org/2/library/queue.html – Alex Yu Jun 12 '18 at 08:46
  • @KlausD. You're right. It was an issue of the right Py version. It seems to have solved that issue with Py 3.5.5 (passed via runtime). – KRW4 Jun 12 '18 at 09:22

1 Answers1

0

As mentioned in the comments by @KlausD, it seems like you have the wrong version of Python installed. On Cloud Foundry, you would set the version by including a file called runtime.txt in the root of your project (i.e. the directory from which you're running cf push).

https://docs.cloudfoundry.org/buildpacks/python/index.html#runtime

That file is used to tell the Python buildpack which version of Python to install for you. Suggestions would be python-3.5.x or python-3.6.x which would install the latest 3.5 or 3.6 release. You can specify an exact version like python-3.5.5 but it's not recommended as it's easy to forget to update that file when new versions of Python come out.

You can see which versions of Python are supported by the buildpack here.

https://buildpacks.cloudfoundry.org/#/buildpacks/python/v1.6.17

(Note that link goes to the latest version of the buildpack at the time I wrote this, it will get out of date. In the future, just click the most recent version of the buildpack to see what ships with it).

Daniel Mikusa
  • 13,716
  • 1
  • 22
  • 28