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

Eikon API installation Python

Dear all,

we tried to log in with the library, after installing eikon module on Anaconda prompt (base). The installation was successful but I cannot import on Python. I have the following error,

SyntaxError: EOL while scanning string literal

This is the first time I try to install this API.

Thank you for your help

Clémence

eikon#technologyapi
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
23.8k 52 17 14

Hello @ClemenceD

Please be informed that I do not understand what you are trying to do. Why are you using both Conda and Python venv at the same time?

However, my recommendation is to use the Conda only and ignore the Python venv.

The steps are based on the Setting up a Python development environment tutorial but change to RD-Library instead.

Firstly, please ignore the Conda base environment. It is a “best practice” to avoid installing additional packages into your base software environment. Additional packages needed for a new project should always be installed into a newly created Conda environment.

Secondly, create a new Conda Python environment to install and run the Refinitiv-Data Library.

Stay in the based environment, and create a new environment with the following command.

(base) P:\> conda create --name RD_Eikon python=3.9

The example above creates a new environment name "RD_Eikon" with Python version 3.9.x. Please note that you can change the environment name and Python version based on your preference.

Once the creation process is completed, run the following command to activate the RD_Eikon environment.

(base) P:\>conda activate RD_Eikon
(RD_Eikon) P:\>

Now you got the Conda Python environment named "RD_Eikon" which is equivalent to the one you have created with the Python venv.

conda-eikon-1.png

Next, install the RD Library Python (or other Libraries) in this newly created environment. Please be noticed that the RD_Eikon environment must be activated ( (RD_Eikon)...).

(RD_Eikon) P:\> pip install refinitiv-data 

If you want to install other Libraries, just run "pip install" command while in the RD_Eikon environment.

(RD_Eikon) P:\> pip install python-dotenv jupyterlab matplotlib 

Fourthly, code and run the application while you are in this RD_Eikon environment.

conda-eikon-2.png

Finally, if you want to exit the RD_Eikon environment, just run the following command and the current Anaconda prompt will be back to the base environment

(RD_Eikon) P:\> deactivate
(base) P:\>

You can activate the RD_Eikon environment again from any folder with the Anaconda prompt:

(base) C:\>Other Directory> conda activate RD_Eikon
(RD_Eikon ) C:\>Other Directory> 

Hope this helps.

There are other resources that might help you with Conda environment too.



conda-eikon-1.png (30.0 KiB)
conda-eikon-2.png (40.9 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.

Upvote
5.3k 21 2 4

Hi @ClemenceD,


The error code you are sharing here suggests an error in the syntax of your code. Would you mind 1st trying pip installing the library (and also the Refinitiv Data Library, which is the newer version), and then sharing a screenshot of the error with us?

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.

Hello @ClemenceD

Additionally, you can follow the step-by-step Quick Start and Tutorials from the following resources:

The Eikon Data API is now part of the RD Library, if you need step-by-step Eikon Data API tutorials, it is available here.

Upvotes
1 0 1 1

Hi Jonathan,

Thanks for your answer. Now I have another issue. I installed the eikon module, successfully it seems. then when I try to import I do not manage as python tells me there is no eikon module... Please see the screenshots attached.capture1.pngcapture2.png


capture1.png (22.4 KiB)
capture2.png (6.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.

Upvotes
76.6k 238 52 72

@ClemenceD

According to the screenshot, you installed the Eikon library, not Refinitiv Data library. Therefore, you need to remove the "import refinitiv.data.eikon as ek" line.

The code should look like this:

1672825794607.png

If it still shows the "ModuleNotFoundError: No module named 'eikon'", please run the below code to check the Python environment used by the application.

import site
print(site.getsitepackages())
print(site.getusersitepackages())

The Eikon library must be installed in those paths.



1672825794607.png (53.3 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.

Upvotes
1 0 1 1

I have a different path (C:..) than where my environment is located (P:...), isn't possible to have install where my environment is, i.e by changing the package site? path-environment.pngpath-packages.pngImage Caption


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.

Upvote
23.8k 52 17 14

Hello @ClemenceD

According to the screenshot, the first line is using Anaconda environment:

(base) P:\>...

the second line using the native Python virtual environment (aka "venv") which is another Python virtual environment

(P:\>...myPython) P:\>...

Please be informed that both Anaconda environment and Python venv are separate Python virtual environments. They do not share libraries across them.

  • If you installed RD Library (or other Python libraries) in the Anaconda environment, you need to run the application using Anaconda environment (while you are in the (base) prompt), not the Python venv.
  • If you want to run the application using Python venv, you need to install the library in the venv again (while you are in the venv prompt)

Please note that you do not need both Anaconda and Python venv at the same time. Anaconda (or MiniConda) virtual environment can replace Python venv and you can create multiple Anaconda environments as much as you want to support various requirements of the libraries.

More detail about Anacona vs Python venv are as follows:


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

Hello @wasin.w,

I am trying to change the path as suggested, so that I could install the module but I don't manage to go to a proper environment on the C:.... Any advice you may have is welcome.



1673536543784.png


1673536543784.png (21.7 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.

Upvotes
1 0 1 1

Hi @wasin.w,

Thank you for your detailed answer. I am new to Python so I am not sure I get the difference between conda and python nenv yet... I was advice to use the base for installing packages by colleagues because of the firewall from my company. I tried to follow your steps anyway, and I cannot go through all of them (see screenshot).

1673946893433.png


1673946893433.png (54.8 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.

Upvotes
76.6k 238 52 72

@ClemenceD

If you are unable to install libraries in a virtual environment, you need to run an application in the base.

Otherwise, you need to install the library offline. For more information, please refer to this Offline Installation for Eikon Data APIs (Python) article.

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

Hi @Jirapongse,

I am not able to follow the steps from the link you sent: even if the installation seems successful, I don't find the eikon as shown below:

1674060536183.png


1674060536183.png (173.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.

Upvotes
23.8k 52 17 14

Hello @ClemenceD

Thank you for the explanation. The Python virtual environment is a comment technique used in Python development. It helps developers create isolated lightweight virtual Python environments to run each (or multiple) projects with different library sets and versions. Each virtual environment has its own Python binary, and libraries, and cannot share libraries across environments.

There are multiple tools that can create and manage Python virtual environments like Conda (the one with the base environment), the Python native venv, the Virtualenv, and much more.

By default, the virtual environment cannot access libraries in other environments (like in this case, you P:\>...myPython env cannot access libraries in a Conda base environment).

However, there is a workaround to let the venv access the library in a conda base environment.

You may create a new venv under your current Conda base environment with the --system-site-packages argument to let the venv can access the Libraries in Conda base (which include the RD Library).

(base) P:\> python -m venv venv --system-site-packages

Once you activate this venv environment, it should be able to access all libraries that already installed in Conda's base. You can try this and see the pip list result

(base) P:\> python -m venv venv --system-site-packages
(base) P:\>venv\Scripts\activate.bat
(venv) P:\>
(Venv) P:\>pip list
Package                 Version
----------------------- ---------
XXXXX                    XXXXX <-- Result should contain RD Library

I did a quick test in my environment with the cowsay as a test library, the venv created from Conda's base can access the cowsay library in the base.

test-result.png

### Other Option 1 ###

Alternatively, you can run the Python code with just Conda base env like suggest by my colleague.

### Other Option 2 ###

If you really need the Python venv, you can re-install the RD Library Python while you are in the P:\>...myPython env venv.

(base) P:\>venv\Scripts\activate.bat
(venv) P:\>
(venv) P:> pip install refinitiv-data 

Hope this helps.





test-result.png (76.5 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.

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.