简体   繁体   中英

How to import Cloudant module to manipulate existing documents via IBM cloud server less function python 3.9 actions?

I am new to Cloud SDK, and I tried to invoke the following action, but I get error : " stderr: ModuleNotFoundError: No module named 'cloudant'",.

  • NOTE :

  • Console ==> IBM cloudant python 3.9 SDK: No module named 'cloudant'"

  • CLI ==> Python 3.86 : accepted the module without error

  • Question :==> I need to know how to do it using the CLI.

If you have a solution please let me know in time. Thank You!!.

from cloudant.client import Cloudant
import requests
import json
   

dict = {"COUCH_USERNAME": "--bluemix",
"IAM_API_KEY": "---bluemix"}

 def main(dict):
        client = Cloudant.iam(user_name=dict["COUCH_USERNAME"],
        api_key=dict["IAM_API_KEY"],
        connect=True)
        my_database=client['reviews']
        return my_database.json```

Yes I did. I have used Python 3.7 and it works. However, it is depreciated on IBM cloud

The Python cloudant module is EOL and is replaced by the ibmcloudant module .

As per the Functions documentation the 3.9 runtime contains the new ibmcloudant module.

You should migrate your action code to use ibmcloudant instead of cloudant . If you can't want to migrate your code then you could force it to use the 3.7 runtime with --kind python:3.7 or create a custom 3.9 runtime with the cloudant module installed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM