I tried to use the Mendeley SDK and I'm having some problems. I already set the virtual environment and installed the Mendeley package but still I cant make work the code. As far as I can understand the following response it's because something in the virtual environment or in the mendeley package is not working, can someone tell me what should I do next
I used this code which I found in: Authentication issue in mendeley Python SDK
client_id = 1
client_secret = "XXXXXXXXX"
redirect_uri = "http://localhost:8080/testing"
from mendeley import Mendeley
# These values should match the ones supplied when registering your application.
mendeley = Mendeley(client_id, redirect_uri=redirect_uri)
auth = mendeley.start_implicit_grant_flow()
# The user needs to visit this URL, and log in to Mendeley.
login_url = auth.get_login_url()
import requests
res = requests.post(login_url, allow_redirects = False, data = {
'username': 'xxxx@gmail.com',
'password': 'xxxxx'
})
auth_response = res.headers['Location']
# After logging in, the user will be redirected to a URL, auth_response.
session = auth.authenticate(auth_response)
print(session.files.list().items)
After I made added the info needed to access the API I get this response:
(VEnv_Mendeley_v2) C:\Users\rafae\Pictures\Mend\mendeley-api-python-catalog-example-master>py otromendeley.py
Traceback (most recent call last):
File "C:\Users\rafae\Pictures\Mend\mendeley-api-python-catalog-example-master\otromendeley.py", line 6, in <module>
from mendeley import Mendeley
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\mendeley\__init__.py", line 7, in <module>
from mendeley.auth import MendeleyClientCredentialsAuthenticator, \
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\mendeley\auth.py", line 4, in <module>
from requests.auth import HTTPBasicAuth
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\__init__.py", line 58, in <module>
from . import utils
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\utils.py", line 26, in <module>
from .compat import parse_http_list as _parse_list_header
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\compat.py", line 7, in <module>
from .packages import chardet
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\packages\__init__.py", line 3, in <module>
from . import urllib3
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\packages\urllib3\__init__.py", line 10, in <module>
from .connectionpool import (
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\packages\urllib3\connectionpool.py", line 38, in <module>
from .response import HTTPResponse
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\packages\urllib3\response.py", line 5, in <module>
from ._collections import HTTPHeaderDict
File "C:\python\Mendeley\VEnv_Mendeley_v2\Lib\site-packages\requests\packages\urllib3\_collections.py", line 1, in <module>
from collections import Mapping, MutableMapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Users\rafae\AppData\Local\Programs\Python\Python311\Lib\collections\__init__.py)