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
0 1 1 3

Eikon script not working

We have a python script that we use internally to get some financial data on a universe of companies and the script works for one employee but not for me. We have tried various solutions but it seems that there is a problem with my computer/setup rather than the script and i need help fixing it. I am logged into the Eikon platform when running the script. I have all the relevant keys installed. The error that is returned is:


EikonError: Error code 401 | Eikon Proxy not running or cannot be reached. Please read the documentation on troubleshooting


Before this, the other warnings returned are:


Error: no proxy address identified.

Check if Eikon Desktop or Eikon API Proxy is running.


Error on handshake url http://127.0.0.1:None/api/handshake : UnsupportedProtocol("Request URL is missing an 'http://' or 'https://' protocol.")


LocalProtocolError("Illegal header value b'c52a871a9de145769ef77d8f71024c2c5b35773d\\n'")


I am using the same python environment that my colleague uses to run the script so all the packages and versions of them are the same. The script is called from one main file but then calls nine other python files which all run fine on my colleague's computer.


We have tried to fix the problem together but have spent so long on it I just need someone to help from Refinitiv. Thanks in advance.

eikonpythonerror-401handshake
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
32.2k 40 11 20

Hello @ChrisBaldock ,

Unfortunately, it looks like in your environment, even in the new location, eikon does not get fully installed, with all required dependencies.

Another possibility is that python that is used by your jupyter env is not the same one that is being updated.

You can verify this, and simplify your initial testing, by running outside of Jupyter and Anaconda, if you are interested:

Open a command shall and do

python --version

If the version is the same as you are using from Jupyter,

Next do:

python -m pip list

Do you see eikon and other modules that you require- you are ready to test command line. Otherwise, point to the python environment that you intend to use, as it is not the first in the path for example

c:\\Python310\python -m pip list

and you will need to include the explicit path at every next step, or modify your system path so this python env is found first in the path.

Create a small test named "test.py":

import eikon as ek

ek.set_app_key('YOURVALIDAPPKEYHERE')

df, err = ek.get_data(['GOOG.O','MSFT.O', 'FB.O'], 
                      [ 'TR.Revenue','TR.GrossProfit'])
print(df)

and run

python test.py

what do you see? I see:

(base) PS C:\Temp> python test.py
  Instrument       Revenue  Gross Profit
0     GOOG.O  257637000000  146698000000
1     MSFT.O  168088000000  115856000000
2       FB.O  117929000000   95280000000
(base) PS C:\Temp>

If instead you see the same error as before, this would indicate that your eikon and all prerequisites are not fully installed. uninstall eikon command line:

python -m pip uninstall eikon

then

python -m pip install eikon

and observe any errors or warnings that happen on installation.

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
32.2k 40 11 20

Hello @ChrisBaldock ,

Please see this previous discussion thread about similar issue- I hope this is of help, the error that you see is often related to HTTPX incompatibility, let us know.

If this not turns out to be the case, when you mention that your colleague has exact same Python environment, you mean version of python only, or the list of installed modules with versions is also totally identical?

The other possibility I can think of is either your Eikon variant does not include API integration permissions or expired Eikon/Workspace account can also result in a similar-looking API access issue.

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.

Thanks. I tried to downgrade httpx from version 0.22 to 0.14.3 as advised in the first post. I tried to do this using conda and this failed as the message returned said:

"Found conflicts! Looking for incompatible packages.

UnsatisfiableError: The following specifications were found to be incompatible with each other:

Output in format: Requested package -> Available versions"

0.14.3 is available so I'm not sure what it is telling me to do. I then looked into the second option you have provided but i find the COMMON.DEPLOYMENTPORTAL.URL in line 134 of the file and it looks similar to the example provided so i assume this is working. Any suggestions on what to try next? Thanks

Upvotes
32.2k 40 11 20

Hello @ChrisBaldock ,

Next, I would suggest:

1. Refer to article Eikon Data API(Python) Troubleshooting | Refinitiv to verify that your Eikon proxy is listening when you run Eikon.

If you run in Chrome browser address bar?

http://localhost:9060/api/status

Do you see

...ST_PROXY_READY...

response?

However if you do not, then the information that you should collect from logs as described in the article should be used to try to determine the cause. I would also first try to temporarily disable any firewalls or malware blockers that you run, and cleanly restart your Eikon, to see if that changes the response.

2. If/when the proxy is up and running, and you continue facing this issue, I would install a fresh python environment. You can set it up fresh, according to Eikon Data API Quickstart and test with that new Python env.

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.

When running http://localhost:9060/api/status in Chrome the response is:

{"statusCode":"ST_PROXY_READY","version":"3.1.1"}

I followed the instructions above in the first link and received the correct messages at each stage of the process which indicated that the API was working correctly, but when i run the final script I get the 401 Error Code again. I tried creating a new app key and running the tests again but no luck. However when i run each of the four lines one at a time it does work as expected. Though when i try to run my original script I get the same errors as before.

In section 4 of the tests which provides a sample output of API successfully connect to Eikon Desktop(APIProxy), i get this block of code as the result, but i do not get the last line returned which should say "Port 9060 on local proxy was detected"

When checking the TRD folder and the APIProxy.<datetime>.p<process-id>.txt file as stated in the instructions, the fourth line from the bottom states:

[2022-03-30 09:00:29.484|1|data-api|0|WARN] [SetBaggageHeaderMiddleware]Can not receive appKey.

Upvotes
78.6k 248 52 74

@ChrisBaldock

Please try to run the following code in Powershell.

PS C:\Users\U8009686> $body = @{"AppKey"="<your app key>";
>> "AppScope"="trapi";
>> "ApiVersion"="1";
>> "LibraryName"="RDP";
>> "LibraryVersion"="1.1.13";
>> }

PS C:\Users\U8009686> Invoke-WebRequest 'http://127.0.0.1:9060/api/handshake' -Method 'Post' -Body ($body|ConvertTo-Json) -ContentType "application/json"  | Select-Object -Expand Content

The output will contain an access token

{"access_token":"<token>","expires_in":1209600,"token_type":"bearer"}

If it doesn't return an access token, please share the output.

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. I ran this and it produced the expected output in the form you have written.


Upvotes
32.2k 40 11 20

Hi @ChrisBaldock ,

As you have confirmed that Eikon API proxy is running and is listening on the appropriate port, however, python code is still unable to interact successfully with it, I believe that the issue is with the Python environment setup.

I would try the suggestion by @pf from this previous discussion thread:

pip install --upgrade --force-reinstall eikon 

If this does not help, I see two ways you can progress this:

  • Simpler approach, in my opinion, is to install a new, fresh, additional Python environment in a different location on your machine, run that python and and to set it up from scratch for Eikon Data API interaction, per ADAPI Quickstart guide.
  • Another approach, as your colleague's environment is consistent and working, you can try to duplicate it by running on this machine:
pip list

and noting every version of every python module, and next, to upgrade/downgrade your existent python environment fully to the same. Your pip list should become exact same as theirs as the result.

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.

Thanks. I tried the first solution and received this error message:

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'c:\\python310\\lib\\site-packages\\_distutils_hack\\override.py'
Consider using the `--user` option or check the permissions.

I then tried installing it in the same way just for my user account. It worked (with a few warnings) but the script still didn't work.

Regarding the environment, we've exported my colleague's environment from Anaconda as a .yml file and installed it on my machine. This is what we have been using to run the script.

Regarding your final solution, I am following the steps to create another python environment using the quick start guide, which directs me here to installing miniconda, which i can't do for some reason. Once it is installed it is not being recognised in the command prompt. I will message here again when i have found a solution. Thanks.

Hello @ChrisBaldock ,

Access is denied is not a good sign to me, as sometimes is reported in a clear manner and sometimes just fails inside a step. Are you a local admin on your machine? If yes, I would change permissions on the whole c:\\python310 directory, recursively/including subfolders, both to be writeable/not read only and give complete control to all users.

Yes, exporting from Anaconda helps a lot, if you can install the same without conflicts.

You do not have to use Miniconda to install a fresh env as Anaconda works just as well, eikon package should install it's prerequisites ( if it's able to freely operate and to write into filesystem).

After/if you have changed the permissions on the dir, you may wish to uninstall eikon module, and next reinstall it, hopefully without any reported warnings or errors.

Hope this helps

Hi. I changed the permissions for the python301 folder so that it was granted full permissions. I then ran:

pip install --upgrade --force-reinstall eikon 

which ran fine. I tried re-running the script and got the same error.

I created a new environment in anaconda (same location), followed the Eikon Data API QuickStart Guide to install the eikon package (which worked fine). I then opened a new Jupyter notebook and ran:

import eikon as ek

and then script returned "no module named eikon." I then re-ran the first line above for the new environment and received this:

ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'C:\\Python310\\Lib\\site-packages\\~umpy\\.libs\\libopenblas.EL2C6PLE4ZYW3ECEVIV3OXXGRN2NRFM2.gfortran-win_amd64.dll'
Consider using the `--user` option or check the permissions.

I then created a new environment in a new location and after running:

import eikon as ek

I got "TypeError: An asyncio.Future, a coroutine or an awaitable is required"

Any thoughts?

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.