watson-developer-cloud / python-sdk

:snake: Client library to use the IBM Watson services in Python and available in pip as watson-developer-cloud
https://pypi.org/project/ibm-watson/
Apache License 2.0
1.46k stars 827 forks source link

AttributeError: 'DiscoveryV2' object has no attribute 'list_documents' #832

Closed giacomobartoli closed 1 year ago

giacomobartoli commented 1 year ago

This snippet of code is returning an error. Params are correct. Double checked.

from ibm_watson import DiscoveryV2
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

authenticator = IAMAuthenticator('my-apikey')
discovery = DiscoveryV2(
    version='2020-08-30',
    authenticator=authenticator
)
discovery.set_service_url('https://api.eu-de.discovery.watson.cloud.ibm.com')
details = discovery.list_documents('WDS_PROJECT_ID', 'WDS_COLLECTION_ID).get_result()

SDK Version AttributeError: 'DiscoveryV2' object has no attribute 'list_documents'

SDK Version Version: 5.2.3 Summary: Client library to use the IBM Watson Services Home-page: https://github.com/watson-developer-cloud/python-sdk Author: IBM Watson Author-email: watdevex@us.ibm.com License: Apache 2.0 Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages Requires: ibm-cloud-sdk-core, python-dateutil, requests, websocket-client

Additional information:

Additional context Adapting a custom backend from Watson Discovery v1 to Watson Discovery v2. I a colleague from IBM Consulting, feel free to reach me out on Slack (@Giacomino)

giacomobartoli commented 1 year ago

Solved. ibm_watson > 7 is needed. Thus:

pip install --upgrade "ibm-watson>=7.0.0"