0

I have a Python Flask app on my laptop that successfully accesses the Watson Language Translator on Bluemix precisely as described in the Bluemix API Documentation

from watson_developer_cloud import LanguageTranslatorV2 as LanguageTranslator
language_translator = LanguageTranslator(
   username='4e93f965-f1ab-407c-a502-xxxxxx',
   password='3zUExxxxxx')
translation = language_translator.translate(
   text='hello there, this is a test',
   source='en', target='fr')
print(json.dumps(translation, indent=2, ensure_ascii=False))

I now want to move my Python Flask app to Bluemix and access the Language Translator service totally within Bluemix. So I can no longer use from watson_developer_cloud import LanguageTranslatorV2 as LanguageTranslator

Precisely how do I access the Language Translation Service within Bluemix using the Language Translation Service credentials?

CDspace
  • 2,639
  • 18
  • 30
  • 36
Lennart
  • 69
  • 6
  • 2
    Why can't you do it the same way? You should still be able to import from watson_developer_cloud. The services are just out there in the cloud - they don't care where they are being accessed from, as long as the credentials are good. – Daniel Toczala Jan 26 '17 at 15:02
  • 2
    Make sure you have a `requirements.txt` file in listing the packages you have installed locally. In this case `watson-developer-cloud` – German Attanasio Jan 30 '17 at 15:48

1 Answers1

3

When running python on Bluemix (or most other cloud hosting providers), the standard way of defining dependencies is via a requirements.txt file. The bluemix server runs commands to read this file and install the dependencies listed there.

You can see complete documentation at https://pip.pypa.io/en/stable/user_guide/#requirements-files but the basic version is just a file with one line like so:

watson-developer-cloud

Take a look at https://github.com/watson-developer-cloud?utf8=%E2%9C%93&q=python&type=&language=python for several example python apps which use watson-developer-cloud and can be deployed to bluemix.

Nathan Friedly
  • 7,837
  • 3
  • 42
  • 59