I am receiving the following error message after I register my app with reuters through the pytho...

Best Answer
-
Hi, not sure if I should open a separate thread, however I have also been getting exactly the same error message. I am using the 1.1.5 Eikon Data API version. I also tried the http3==0.6 workaround suggested in the post above without any luck. Is there an alternative workaround? Would updating to Python 3.7 fix this issue?
Thank you.
0
Answers
-
Error Message:
AttributeError: 'NoneType' object has no attribute 'status_code'
0 -
Would you mind including the line of code that raises this exception? Or even better include the full trace.
0 -
Hello @michael-r.meyer
Could you please also let us know the version of Eikon data API that you are using? You can check the version dynamically via the following statement:
import eikon as ek
ek.__version__0 -
0
-
The eikon version is 1.1.5
Python is 3.6
The lines of code that produce this error is:
import eikon as eik
eik.set_app_key('xxxxxxxxxxxxxx')
heads = eik.get_news_headlines('AAPL.O',count = 1)
error here ---^
0 -
Please try this code by setting the log level to 1.
import logging
import eikon as ek
print(ek.__version__)
ek.set_app_key('<app_key>')
ek.set_log_level(1)
ek.get_news_headlines("AAPL.O",count=10)You should see an exception. Please share the exception.
0 -
This may not be the exact same issue that you are facing - but an internal user had a very similar error message/ usage scenario and it was down to an incompatible version of http3 library when using Python 3.6
For that user, the following resolved the issue:
pip uninstall http3
pip install http3==0.6An alternative option would be to try Python 3.7 which the RDP library dev team advises they have validated and certified with this version.
0 -
Hi -
I set log level to 1 and get the following exception thrown:
1.1.5
2020-09-01 07:44:18,751 P[4776] [MainThread 5192] HTTP request failed: RuntimeError('read() called while another coroutine is already waiting for incoming data',)
0 -
Running this code with logger:
- import logging
- import eikon as ek
- print(ek.__version__)
- ek.set_app_key('<app_key>')
- ek.set_log_level(1)
- ek.get_news_headlines("AAPL.O",count=10)
I get the following error:
2020-09-01 10:34:56,339 P[4776] [MainThread 5192] HTTP request failed: RuntimeError('read() called while another coroutine is already waiting for incoming data',)
0 -
I got the same error when using Python 3.6.8 and http3-0.6.7.
2020-09-02 11:26:44,511 P[19616] [MainThread 9404] HTTP request failed: RuntimeError('read() called while another coroutine is already waiting for incoming data',)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\venvs\3.6.8\lib\site-packages\eikon\news_request.py", line 121, in get_news_headlines
result = eikon.json_requests.send_json_request(News_Headlines_UDF_endpoint, payload, debug=debug)
File "C:\venvs\3.6.8\lib\site-packages\eikon\json_requests.py", line 94, in send_json_request
logger.debug('HTTP Response code: {}'.format(response.status_code))
AttributeError: 'NoneType' object has no attribute 'status_code'You can try a workaround by using http3==0.6,as mentioned by my colleague.
pip uninstall http3
pip install http3==0.60 -
I have been advised by the RDP Dev team that they were able to reproduce what appears to be the same issue (i.e. same error message etc) with Python 3.6 - but could not be reproduced with 3.7 and also that version 1.1.5 of the Eikon library has been tested + qualified with Python 3.7 (but not 3.6)
Therefore, if you are able to test with v3.7 please do so.
0 -
Hi, thanks for getting back to me. I just checked this internally and our IT policy prevents us from moving to Python 3.7 at least for another year. Could this fix be applied to Python 3.6?
0 -
Eikon Data APIs Python library v1.1.6.post2 is now available from PyPI. We believe this version of the library addresses various connection problems some users experienced with Eikon Data APIs Python library v1.1.5. Could you update the version of Eikon Data APIs Python library on your machine to v1.1.6.post2 and reply back on this thread if it helped?
0 -
Thanks, looks like this has been resolved on my side.
0 -
Hi -
I found that installing Python 3.7 or above solved the problem. No error after that.
Thanks
0 -
When I upgraded to Python 3.7+ issue with current library was resolved.
0 -
Untitled1
NoneType object has no attribute status_code¶
I had this exact same issue and tracked it back to a timeout in the nest_asyncio.py dependency.
In [3]:import eikon as ek
Out[3]:
ek.__version__'1.1.5'
This is just a helper function to demonstrate the source code we're looking at.
In [8]:import inspect
def show_source_code(module, start_line, end_line):
source = inspect.getsource(module)
lines = source.split("\n")
num_lines = len(lines)
if start_line > num_lines:
return ""
if end_line > num_lines:
end_line = num_lines
print("\n".join(lines[start_line:end_line]))Within the eikon package there is a 'json_requests.py' module containing the function 'send_json_request'.
This request gets a response from calling a http_request method.
However, if this request fails it'll get response = None (say a timeout).When try: logger.debug is called in the final line below it'll attempt to reference the status_code attribute of None and throw an attribute error.
In [21]:show_source_code(ek.json_requests, 84, 94)
# build the request
In [23]:
udf_request = {'Entity': {'E': entity, 'W': data} }
logger.debug('Request:{}'.format(udf_request))
response = profile._desktop_session.http_request(url=profile.get_url(),
method="POST",
headers={'Content-Type': 'application/json',
'x-tr-applicationid': profile.get_app_key()},
json=udf_request)
try:
logger.debug('HTTP Response code: {}'.format(response.status_code))None.status_code
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-23-be7a3e11c091> in <module>
----> 1 None.status_code
AttributeError: 'NoneType' object has no attribute 'status_code'This sent me on a bit of a hunt for the underlying issue... I'll spare you the steps inbetween, but I ended up having to fiddle with the timeout variable in the nest_asyncio.py dependency.
In [27]:import nest_asyncio
In [32]:show_source_code(nest_asyncio, 71, 74)
timeout = 0 if ready or self._stopping \
else min(max(0, scheduled[0]._when - now), 10) if scheduled \
else NoneIf left unaltered then we'll end up with the issue you're seeing.
In [1]:APP_KEY = "..."
In [2]:import eikon as ek
In [3]:
ek.set_app_key(APP_KEY)ek.get_news_headlines("AAPL.O",count=10)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-3-4b16f70155ba> in <module>
----> 1 ek.get_news_headlines("AAPL.O",count=10)
C:\Anaconda2\envs\py36\lib\site-packages\eikon\news_request.py in get_news_headlines(query, count, date_from, date_to, raw_output, debug)
119 payload.update({'dateTo': to_datetime(date_to).isoformat()})
120
--> 121 result = eikon.json_requests.send_json_request(News_Headlines_UDF_endpoint, payload, debug=debug)
122
123 if raw_output:
C:\Anaconda2\envs\py36\lib\site-packages\eikon\json_requests.py in send_json_request(entity, payload, debug)
92 json=udf_request)
93 try:
---> 94 logger.debug('HTTP Response code: {}'.format(response.status_code))
95 logger.debug('HTTP Response: {}'.format(response.text))
96 except UnicodeEncodeError as unicode_error:
AttributeError: 'NoneType' object has no attribute 'status_code'And that's what I was seeing...
However, we can modify the code in nest_asyncio and it'll work. Yes, it's a hack, but it'll work until the devs clean things up.
I incremented the timeout as follows (by adding 3 extra lines at the end):
In [9]:import inspect
import nest_asyncio
show_source_code(nest_asyncio, 71, 77)timeout = 0 if ready or self._stopping \
else min(max(0, scheduled[0]._when - now), 10) if scheduled \
else None
if timeout is not None:
if timeout > 0:
timeout = 20And if you try it again:
In [4]:ek.get_news_headlines("AAPL.O",count=1)
Out[4]:
versionCreatedtextstoryIdsourceCode2020-09-23 19:53:50.8892020-09-24 06:05:51.489000+00:00Reuters Insider - The "no matter what" stocks:...urn:newsml:reuters.com:20200923:nRTV28VXrs:13NS:RTRS
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 684 Datastream
- 1.4K DSS
- 614 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 641 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 89 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛