IBM / python-sdk-core

The python-sdk-core repository contains core functionality required by Python code generated by the IBM OpenAPI SDK Generator.
Apache License 2.0
20 stars 27 forks source link

Import errors with requests excpetions #158

Closed walterpl closed 1 year ago

walterpl commented 1 year ago

Hello team.

I'm using secret-manager-python-sdk to recover some credentials on cloud, but, since the yesterday update the sdk stop working, after some investigation the problem is with the import of the python-sdk-core.

/opt/conda/envs/Python-3.9/lib/python3.9/site-packages/ibm_cloud_sdk_core/__init__.py in <module>
     37 """
     38 
---> 39 from .base_service import BaseService
     40 from .detailed_response import DetailedResponse
     41 from .token_managers.iam_token_manager import IAMTokenManager

/opt/conda/envs/Python-3.9/lib/python3.9/site-packages/ibm_cloud_sdk_core/base_service.py in <module>
     26 import requests
     27 from requests.structures import CaseInsensitiveDict
---> 28 from requests.exceptions import JSONDecodeError
     29 
     30 from ibm_cloud_sdk_core.authenticators import Authenticator

ImportError: cannot import name 'JSONDecodeError' from 'requests.exceptions' (/opt/conda/envs/Python-3.9/lib/python3.9/site-packages/requests/exceptions.py)

I took a look at the requests project and the JSON encoder exception was included in this commit :

That version is 2.28X and the requirements for this project ask for at least 2.26.X onwards, the problem is that my project is already using 2.26.0, so it won't update.

So I would like to ask if is possible to raise the version on the requirements to solve this issue.

Thanks and Best Regards.

walterpl commented 1 year ago

So, I managed to update the version before compiling, so I will close this issue.

Thanks anyway guys!

padamstx commented 1 year ago

I'm glad you got it working, but I will go ahead and fix the imported version in the python core so others can avoid the same fate (potentially).

nrocaalh commented 5 months ago

Hi, I'm having the same error, I'm using ibm-cloud-sdk-core version 3.18.2 and requests version 2.28.2

File "/usr/local/lib/python3.8/site-packages/ibm_cloud_sdk_core/base_service.py", line 29, in <module> from requests.exceptions import JSONDecodeError ImportError: cannot import name 'JSONDecodeError' from 'requests.exceptions' (/home/default/.local/lib/python3.8/site-packages/requests/exceptions.py)

I understand this issue was fixed, so I don't know if this is a version issue or other thing.

Thanks

dpopp07 commented 5 months ago

@nrocaalh try using v3.20.0 (the latest version) and let us know if the problem persists.

nrocaalh commented 5 months ago

Hi, I tried with the latest version and the error persists. Thanks

pyrooka commented 5 months ago

Hello @nrocaalh! Can you make sure you are also using the latest version of the requests package? Please run the following command in your project to check the package version: python -c 'import requests; print(requests.__version__)' To obtain the most recent version, you can run this command pip install -U requests, but you should always use the version that's specified in the requirements.txt file.

(The JSONDecodeError class was added in 2.27.0, so it should be there if you are on the latest version.)