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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
1 0 0 1

Error while running set_app_id("xxxx")

Hi everyone! I'm trying to connect Reuters using python (with spyder), following the Eikon Data API quick start guide for Windows. I already created an App Key.

I use the following code:

import sys
import os
import eikon as ek
from eikon import Profile as profile
ek.set_app_id('xxxx')

And the last line gives me the following error:
File "C:\Users\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\Profile.py", line 270, in <listcomp>
for app_name in app_names if os.path.isdir(user_data_dir(app_name, app_author, roaming=True))]

NameError: name 'os' is not defined

Could someone please help me solving this problem?

Thanks!

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
icon clock
10 |1500

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

Upvotes
Accepted
39.2k 75 11 27

As I expected the library published on Github is not an official release from Refinitiv, as stated in the disclaimer in the readme.
I can't say I have an explanation for the latest AttributeError you experienced. It makes no sense to me. The error means that deprecation module is available, but there's no function named 'deprecated' in that module. Assuming you installed the latest version 2.0.6 of the module, 'deprecated' function must be there. You should be able to see it by opening deprecation.py file in site packages folder. You can also verify it by running

import deprecation
help(deprecation.deprecated)
I'm afraid I'm at a loss as to what might be the root cause here. And I'm out of suggestions for what you could try to work around it short of rebuilding your development environment.
icon clock
10 |1500

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

Upvotes
39.2k 75 11 27

This is rather puzzling. Could you provide the full stack trace for the error?
Importing Profile module from eikon library is unnecessary. Not that it should cause the problem you experienced, but what if you only keep the bare necessities and remove all other imports? Try executing just the two lines below. Do you get the same error?

import eikon as ek
ek.set_app_id('xxxx')
icon clock
10 |1500

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

Upvotes
1 0 0 1

Thanks for your answer. I tried the above two line scripts and I get the same error. I tried to solve the problem by importing os, setting the directory, importing appdirs. The full stack trace for the error:

import eikon as ek
ek.set_app_id('xxxx')
Traceback (most recent call last):

File "<ipython-input-105-ab41b27985c7>", line 2, in <module>
ek.set_app_id('xxxx')

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\Profile.py", line 32, in set_app_id
get_profile().set_application_id(app_id)

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\Profile.py", line 141, in set_application_id
self.set_port_number(identify_scripting_proxy_port(self.session, self.application_id))

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\Profile.py", line 270, in identify_scripting_proxy_port
for app_name in app_names if os.path.isdir(user_data_dir(app_name, app_author, roaming=True))]

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\Profile.py", line 270, in <listcomp>
for app_name in app_names if os.path.isdir(user_data_dir(app_name, app_author, roaming=True))]

NameError: name 'os' is not defined

I have to say that I have tried to install eikon package (and others) using command and conda prompt without any success. In this device the only way I have to install packages is to download them from github and manually to put them in

C:\Users\1938809\AppData\Local\Continuum\anaconda3\Lib\site-packages folder. However I have no error while I import eikon.

icon clock
10 |1500

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

Upvotes
39.2k 75 11 27

I can't say I have an explanation for the error you encountered. It makes no sense to me. Which version of eikon library did you install? You can find out by calling ek.__version__.
set_app_id command is deprecated. Try replacing it with set_app_key. Still the same error?
Do I understand correctly that you have no problem using os module in your code? E.g. the following works fine for you?

import os
os.environ['HOME']
icon clock
10 |1500

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

Upvotes
1 0 0 1

Hi,

-eikon version installed is 0.1.12, the one available on github

-I tried to download this packages files (eikon 1.0.1): https://pypi.org/project/eikon/#files. And I get this error while importing eikon:

import eikon as ek
Traceback (most recent call last):

File "<ipython-input-3-7b8635881a63>", line 1, in <module>
import eikon as ek

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\__init__.py", line 12, in <module>
from .Profile import set_app_key, get_app_key,\

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\Profile.py", line 13, in <module>
import deprecation

ModuleNotFoundError: No module named 'deprecation'

-Replacing set_app_id by set_app_key gives me this error:

ek.set_app_key('xxxx')
Traceback (most recent call last):

File "<ipython-input-19-98c3c348597c>", line 1, in <module>
ek.set_app_key('xxxx')

AttributeError: module 'eikon' has no attribute 'set_app_key'

-No problem using os module in my computer.

I can set the directory using os.chdir("...")

And, as I'm on Windows the above code works property

In[17]:os.environ['USERPROFILE']
Out[17]: 'C:\\Users\\1938809'

icon clock
10 |1500

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

Upvotes
39.2k 75 11 27

I'm not aware of Eikon Data APIs library for Python having been made available on Github. If you could provide a link, I'll take a look and see if it was posted by Refinitiv. But in any case version 0.1.12 is old and shouldn't be used any more. I suggest we focus on installing the latest version 1.0.1. ModuleNotFoundError you experienced after manually installing eikon library v1.0.1 is not unexpected. When you manually install a package downloaded from PyPI you also have to manually install all the dependencies you don't already have installed, then the dependencies of the dependencies and then the dependencies of the dependencies of the dependencies and so on. This is painful, but there's no way around it if you cannot use PIP or conda to automatically install all the dependencies at once. Here's the deprecation module you're missing.
https://pypi.org/project/deprecation/

icon clock
10 |1500

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

Upvotes
1 0 0 1

GitHub link: https://github.com/dhirschfeld/eikon

Ok, now I installed eikon 1.0.1. And the deprecation package. Got the following error:

import deprecation
import eikon as ek
Traceback (most recent call last):

File "<ipython-input-5-7b8635881a63>", line 1, in <module>
import eikon as ek

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\__init__.py", line 12, in <module>
from .Profile import set_app_key, get_app_key,\

File "C:\Users\1938809\AppData\Local\Continuum\anaconda3\lib\site-packages\eikon\Profile.py", line 16, in <module>
@deprecation.deprecated(deprecated_in="0.1.12", removed_in="1.1.0",

AttributeError: module 'deprecation' has no attribute 'deprecated'

icon clock
10 |1500

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

Click below to post an Idea Post Idea