Error - ModuleNotFoundError: No module named 'requests_cache'
Hi @faaez , I'm trying to use your package in R (through reticulate).
I used the py_install function in reticulate to install the package, which appears to have worked
py_install("git+git://github.com/faaez/capiq-python.git", pip = TRUE)
Collecting git+git://github.com/faaez/capiq-python.git
Cloning git://github.com/faaez/capiq-python.git to c:\users\user\appdata\local\temp\pip-req-build-di6bexg5
Running command git clone -q git://github.com/faaez/capiq-python.git 'C:\Users\user\AppData\Local\Temp\pip-req-build-di6bexg5'
Building wheels for collected packages: capiq-python
Building wheel for capiq-python (setup.py): started
Building wheel for capiq-python (setup.py): finished with status 'done'
Created wheel for capiq-python: filename=capiq_python-0.1-py3-none-any.whl size=5075 sha256=98524e8be4e1a481e98e8540ec0e846da43d9245fbe3be6258d82fe86c1f7f7c
Stored in directory: C:\Users\user\AppData\Local\Temp\pip-ephem-wheel-cache-ywpcow2t\wheels\e1\e0\7e\1d4caae461356a3f609e1033cc27f641cb22111c59cf6fe9f9
Successfully built capiq-python
Installing collected packages: capiq-python
Attempting uninstall: capiq-python
Found existing installation: capiq-python 0.1
Uninstalling capiq-python-0.1:
Successfully uninstalled capiq-python-0.1
Successfully installed capiq-python-0.1
However, when I try to run the following lines (using my username and password of course).
from capiq.capiq_client import CapIQClient
ciq_client = CapIQClient("Username", "Password"
I get the following error
Error in py_run_file_impl(file, local, convert) :
ModuleNotFoundError: No module named 'requests_cache'
Any idea what the issue could be?
pip install requests_cache resolves the issue.
Hi @zhiboz, I installed the requests_cache package and ran the following script (running it in R using the py_run_file command in reticulate)
from capiq.capiq_client import CapIQClient
ciq_client = CapIQClient("USERNAME", "PASSWORD")
return_value = ciq_client.gdsg(["TRIP"], ["IQ_CLOSEPRICE"], ["close_price"], properties=[{}])
but now its giving me the following error
Error in py_run_file_impl(file, local, convert) :
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Do you perhaps have access to Capital IQ and can recommend how to overcome this issue?
here is a working example:
ciq_client.gdshe(['WMT:', "ibm:"],['IQ_CLOSEPRICE'], ['close_price'], start_date='11/12/2010',end_date='11/18/2010')
@zhiboz how did you set your username and password universally before you ran that line of code? When i run the following, I still get the same error
from capiq.capiq_client import CapIQClient
ciq_client = CapIQClient("USERNAME", "PASSWORD")
ciq_client.gdshe(['WMT:', "ibm:"],['IQ_CLOSEPRICE'], ['close_price'], start_date='11/12/2010',end_date='11/18/2010')
@zhiboz anyway you could share your script to see how you managed to get this to run? You can obviously censor your username and password out?
Hi @tanga94, I haven't used reticulate so unfortunately can't really help there. Are you able to get the module running in Python?
Re: the original issue, can you confirm that you installed the packages in the requirements.txt file?
Hi @faaez , is this service still operational? I was informed that it isn't
@faaez I have installed all the packages in the requirements.txt file. When I try to this now in Python as opposed to reticulate
ciq_client.gdshe(['WMT:', "ibm:"],['IQ_CLOSEPRICE'], ['close_price'], start_date='11/12/2010',end_date='11/18/2010')
I get this error
send: b'POST /gdsapi/rest/v3/clientservice.json HTTP/1.1\r\nHost: api-ciq.marketintelligence.spglobal.com\r\nUser-Agent: python-requests/2.24.0\r\nAccept-Encoding: gzip,deflate\r\nAccept: */*\r\nConnection: keep-alive\r\nContent-Type: application/json\r\nContent-Length: 303\r\nAuthorization: Basic VGFuZ2VuaS5TaGF0aXdhQGJvbi5jb20ubmE6VGFuZ2VuaTEu\r\n\r\n'
send: b'{"inputRequests": [{"function": "GDSHE", "identifier": "WMT:", "mnemonic": "IQ_CLOSEPRICE", "properties": {"STARTDATE": "11/12/2010", "ENDDATE": "11/18/2010"}}, {"function": "GDSHE", "identifier": "ibm:", "mnemonic": "IQ_CLOSEPRICE", "properties": {"STARTDATE": "11/12/2010", "ENDDATE": "11/18/2010"}}]}'
reply: 'HTTP/1.1 401 Unauthorized\r\n'
header: Date: Sat, 16 Jan 2021 01:39:07 GMT
header: Content-Type: text/html; charset=iso-8859-1
header: Content-Length: 381
header: Connection: keep-alive
header: Server: Apache/2.4.29 (Unix) OpenSSL/1.0.2k-fips
header: WWW-Authenticate: Basic realm="LDAPs Login"
Traceback (most recent call last):
File "<ipython-input-35-1a1f7c6aeab8>", line 1, in <module>
ciq_client.gdshe(['WMT:', "ibm:"],['IQ_CLOSEPRICE'], ['close_price'], start_date='11/12/2010',end_date='11/18/2010')
File "C:\Users\user\anaconda3\lib\site-packages\capiq\capiq_client.py", line 84, in gdshe
return self.make_request(identifiers, mnemonics, return_keys, properties, "GDSHE", True)
File "C:\Users\user\anaconda3\lib\site-packages\capiq\capiq_client.py", line 157, in make_request
if len(response.json()['GDSSDKResponse']) == 1 and \
File "C:\Users\user\anaconda3\lib\site-packages\requests\models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\user\anaconda3\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Users\user\anaconda3\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\user\anaconda3\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
JSONDecodeError: Expecting value
Gotcha. Sorry I’m not able to help since I don’t have a CapIQ subscription anymore.
@zhiboz would you be able to help if this I working for you?
This is the returned header for this error:
401 Unauthorized
Unauthorized
Unauthorized
This server could not verify that you
are authorized to access the document
requested. Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.
CapitalIQ has changed something with api access, the https requests string has changed, or something else. I may clone this on my github/ecjbosu. And try somethings.