0

I would like to use LanguageTranslatorV3 and ToneAnalyzerV3 python library in IBM Cloud function custom serverless action.

I created one sample Action in IBM Cloud function and try to import the above packages, but It gives me module error.

So, How can I install the above modules in my custom action?

Thanks in advance.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
Keval Bhatt
  • 152
  • 1
  • 12

3 Answers3

2

That process of integrating third party libraries is described in the IBM Cloud Functions documentation as part of preparing apps for actions. For Python you could use zip to package the environment, either with or without using virtualenv. Another option for even more complex environments could be to use a Docker image.

The function in this tutorial-related repo uses the zip-approach.

Many packages are already available in the standard Python runtime environments. Be sure to specify the right runtime version when creating the action.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
1

For python, there is a detailed tutorial about how to use custom packages on OpenWhisk(IBM Cloud Functions use this project): http://jamesthom.as/blog/2017/04/27/python-packages-in-openwhisk/, the section Installing Packages With Docker and Speeding Up Deployments make it even better

raja
  • 159
  • 2
  • 7
1

The Python runtime for IBM Cloud Functions does already include the watson-developer-cloud package.

You should be able to use that without manually bundling the packages.

James Thomas
  • 4,303
  • 1
  • 20
  • 26
  • Yes, You may right but when I tried to use `from ibm_watson import LanguageTranslatorV3 ` in python 3.7 runtime environment then It gives me the error that **ibm_watson** module not found. Thanks for your answer. – Keval Bhatt Aug 08 '19 at 15:16
  • `from watson_developer_cloud import LanguageTranslatorV3` worked. Thank you very much the answer – Keval Bhatt Aug 08 '19 at 15:51