Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 0

"ek.set_app_key" in Python Spyder

When run ek.set_app_key(my api key) in spyder it doesnt work. The kernel stays busy and I cannot do anything. On the other hand the command works in my jupyter notbook. Does anyone know how to solve this?

Your help would be much appreciated. Thank you.

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apiapp-key
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
25.3k 87 12 25

Hi @toddc1021

I assume the log file output is for when you run in Spyder? If so, the line Set App Key: None is troubling as this would indicate you are not providing an AppKey?

Your Anaconda screenshot confirms that from Anaconda prompt you are able to connect to Eikon and get a valid response. The key line is Port 9000 on local proxy was detected - which indicates a successful connection.

I have also spoken with the Eikon Data API development team and they can confirm they have never faced any issues when testing with Spyder.

This would seem to narrow this down to an issue with your particular Spyder installation. As Spyder is a 3rd party application the only suggestions I can offer are to try and uninstall and re-install Spyder to see if that helps.

Alternatively, you could use Spyder IDE as your editor to create/edit your script and then run the script from the Anaconda prompt - instead of from within Spyder. I appreciate this is not ideal - but this is a workaround I would consider using as a developer if I could not figure out what was wrong with my IDE.

Failing that there are other IDEs available such as Visual Studio Code.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
25.3k 87 12 25

Hi @toddc1021

Please advise what you mean by does not work?

Do you see any error message / other output?

Please try enabling logging to see if that provides any relevant information e.g.

import logging.config 
ek.set_log_level(logging.DEBUG) 
ek.set_app_key('<your app key>') 

Just to confirm that I did try a quick test in Spyder and it worked fine.

Also, can you confirm what happens if you run a basic script with set_app_key in a Python console?

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hi Umer thank you for the reply. Here is a screenshot. After running the command ek.set_app_key('my api key') everything just froze.

error.png (66.3 KiB)
Upvotes
25.3k 87 12 25

Hi @toddc1021

Thanks for the update.

And can you confirm what happens when you run the script in a standalone console outside of Spyder? e.g. at the Anaconda prompt and a standard Python console invoked directly from Windows (rather than from within Spyder)?

for example:

Also, please confirm the version of eikon library installed

import eikon as ek
ek.__version__

You should also have a Log file generated in the working directory e.g. something like pyeikon.20200424.10-47-44.log - please remove any AppKey etc from the log file before attaching to your reply.

One final thing, have you tried completely shutting down the Eikon application instance and restarting it - we have had the odd occasion where the Eikon library refuses to connect and a restart fixes it. Note that exiting Eikon does not necessarily shut it down - you may have to use the little icons in the bottom left to shut it down completely.



1587721777753.png (88.1 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you Umer.

In Spyder when I type ek.__version__ it tells me '1.1.2'.

I am using Spyder 4.1.2.

Yes I have tried shutting down Eikon and restarting it.

Could you please guide me through "when you run the script in a standalone console outside of Spyder? "

I opened Anaconda prompt as an administrator and tried to type in the command but it doesnt seem to work. A screenshot is attached. Would appreciate if you could provide more detailed steps. Thank you very much.


eikon.png (10.5 KiB)

Hi @toddc1021

In order to run outside of Spyder - create a simple Python script e.g. Test.py - which includes the basic import eikon, set_log_level, set_app_key etc. and then execute the Test.py file in the Anacondata console as I did in my screenshot above - making sure you are in the right directory.

C:\Windows\system32> cd "C:\Refinitiv\RDP.Python\Eikon API"
C:\Refinitiv\RDP.Python\Eikon API> python Test.py

This will help confirm whether your Anaconda installation is valid and the problem is limited to Spyder or not.

The other point is regarding the set_log_level - did you get any additional output? Is there a pyeikon.xxx.log file generated or any additional output displayed in Spyder when you enable the logging?

Unfortunately, if the problem is limited to Spyder - I am not sure how much assistance we could offer as it is a 3rd party product.

Thank you Umer.


Here is the output of the log file:

2020-04-27 13:17:10,097 -- pyeikon -- INFO -- Set App Key: None


2020-04-27 13:17:12,130 -- pyeikon -- INFO -- Response : 500 - {"code":500,"message":"Cannot find module \".\"","statusMessage":"Internal Server Error"}


2020-04-27 13:17:12,131 -- pyeikon -- INFO -- Port 9000 was retrieved from .portInUse file


2020-04-27 13:17:12,131 -- pyeikon -- INFO -- Try to handshake on url http://localhost:9000/api/handshake...


2020-04-27 13:17:12,136 -- pyeikon -- INFO -- Response : 400 - Handshake payload is invalid.


2020-04-27 13:17:12,136 -- pyeikon -- INFO -- Set Proxy port number to 9000


And here is the output from the anaconda prompt after running:

import eikon as ek

import logging.config

ek.set_log_level(logging.DEBUG)

ek.set_app_key('my api key')


Your help would be much appreciated. Thank you.


error-eikon.jpg (78.9 KiB)

I have written it in my first post but just to make sure its clear: I have no problem using eikon api in jupyter notebook. The problem only occurs in spyder.

Upvotes
7.6k 15 6 9

@toddc1021

I can run the latest version of eikon data API 1.1.2 with spyder.

I'm using spyder 4.1.2. Not sure do you have any virus scan or firewall that detecting some behavior and causes it hangs?


spyerder-snap1.jpg (160.2 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thank you Moragodkrit. I am running eikon data api 1.1.2 with Spyder 4.1.2. I, not sure if it has to do with any virus scan but this situation has never occurred when I am using other python packages.

@toddc1021

I mentioned the antivirus or firewall because Eikon Data API has to open an internal communication port to Eikon Desktop. I found a similar issue with spyder last year with another library, and it hangs/freezes like this. Seems like some firewall app in my PC try to block the behavior. I tried to disable windows defender/firewall/antivirus, and it seems to resolve. When I enable it again, the problem seems to disappear. So I don't know what they did.

Thank you Moragodkrit. The app works on jupyter notebook. In that case could it really be an issue with the firewall? Is there a way to test if its the firewall issue without having to turn off the firewall? Im using an organization's laptop so I would avoid doing that.

Upvotes
32.2k 40 11 19

Hello @toddc1021,

I fully agree with @Umer Nalla. In addition, I am thinking that any machine can easily have installed many versions of python, mine sure has many.

If this is the case, the version that is referenced by jupiter, has the correct version of eikon module installed. This version is often in C:\ProgramData\Python\version on windows boxes.

The version of python that is in your system path and found by Spyder by default, can be different. Or even the same, but installed separately, in a different location. Then it would need the latest eikon module to be installed separately on it.

This may not be it, the major version in system path is easy to ascertain, run cmd shell, and in it try

python --version

You can, same way, check if the eikon is installed on that specific python

python -m pip freeze | findstr eikon

Results in

WARNING: Could not generate requirement for distribution -ywin32 224 (c:\programdata\anaconda3\lib\site-packages): Parse error at "'-ywin32='": Expected W:(abcd...)
WARNING: Could not generate requirement for distribution -umpy 1.16.2 (c:\programdata\anaconda3\lib\site-packages): Parse error at "'-umpy==1'": Expected W:(abcd...)
WARNING: Could not generate requirement for distribution - win32 (c:\programdata\anaconda3\lib\site-packages): Parse error at "'-===win3'": Expected W:(abcd...)
eikon==1.1.2

Check the same, within pybook, for comparison.

Hope this info helps

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.