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
Best Answer
-
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.
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.
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.
- Setting Up a Conda Environment in Less Than 5 Minutes
- The Definitive Guide to Conda Environments
- Getting started with conda
0
Answers
-
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?
1 -
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.
0 -
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.
0 -
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:
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.
0 -
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? Image Caption
0 -
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:
- Does Conda replace the need for virtualenv?
- venv vs Anaconda for creating virtual environments
- Pipenv vs virtualenv vs conda environment
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).
0 -
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.
0 -
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:
0 -
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 LibraryI 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.
### 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-dataHope this helps.
0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛