LSEG Data Library in CodeBook vs. a Local Python Environment: Which Should You Use?

Raksina Samasiri
Developer Advocate

Introduction

The LSEG Data Library for Python provides simple interfaces for accessing financial data and services available through LSEG. It allows users to retrieve data, discover instruments, access news, work with pricing streams, and integrate LSEG content into Python applications.

You can use the library in different Python environments. Two common choices for LSEG Workspace users are:

  • CodeBook, a cloud-hosted Jupyter Notebook environment available in LSEG Workspace
  • A local Python environment, such as JupyterLab, Jupyter Notebook, Visual Studio Code, or PyCharm running on your own computer

The Python code used to retrieve data can be similar in both environments. However, the setup, session requirements, package management, file access, and suitability for automation can be different.

This article compares the two environments and helps you decide which one is more appropriate for your workflow.

Note: This article focuses on using an LSEG Workspace entitlement. A Data Platform Session uses a different access model and requires separate Data Platform credentials and entitlements. It is not covered in detail in this article.

TL;DR

  • Use CodeBook if you want to get started quickly in a ready-to-use Jupyter Notebook environment without installing Python or managing packages on your computer.
  • Use a local Python environment if you need more control over your Python version, packages, files, IDE, Git workflow, or integration with other local tools and processes.

The choice of environment does not automatically change your data entitlement or provide additional usage capacity. Your access to data continues to depend on your LSEG subscription, entitlements, session type, and the applicable service limits.

Prerequisites

To follow the examples in this article, you should have:

  • Access to LSEG Workspace
  • Permission to use CodeBook, if you intend to run the example in CodeBook
  • Python installed on your computer, if you intend to use a local environment
  • The LSEG Data Library for Python installed in the local environment
  • Basic familiarity with Python and Jupyter Notebook

The examples use the LSEG Data Library for Python and its Access layer.

For information about the available libraries and their current status, see the Essential Guide to the Data Libraries.
For more data-retrieval examples, see the Data Library for Python Quick Reference Guide.

What is CodeBook?

CodeBook is a cloud-hosted coding environment available in LSEG Workspace. It provides a Jupyter Notebook interface that users can access without setting up a Python environment on their own computer.

The CodeBook environment is managed and controlled by LSEG. LSEG maintains the underlying environment, including the available Python versions, preinstalled libraries, and system configuration. This provides users with a consistent environment and reduces the need for local setup and maintenance. However, users have less control over the environment than they would in a local Python installation.

The environment includes Python, commonly used Python packages, LSEG Data Library access, and example notebooks. This allows users to focus on retrieving and analysing data instead of installing and configuring development tools.

CodeBook is particularly useful for:

  • Learning the LSEG Data Library
  • Exploring LSEG data interactively
  • Running examples and tutorials
  • Creating prototypes
  • Performing ad hoc analysis
  • Delivering training or workshops
  • Users who cannot install development software on their computers

Because CodeBook is available within LSEG Workspace, much of the initial setup is managed by the environment.

Checking the installed libraries in CodeBook

CodeBook provides a list of the Python libraries installed in the current environment. To view the list, open HELP > CodeBook Libraries&Extensions in CodeBook.

The list shows the installed libraries and their versions. Check this information when you need to:

  • Verify the installed library version before running an example
  • Compare the CodeBook environment with a local Python environment
  • Investigate differences in results or behavior between environments

The available libraries and versions may change when the CodeBook environment is updated. Therefore, check the current environment rather than relying on a version shown in an older article or notebook.

Advantages of using CodeBook

  • No local Python installation is required
  • Common Python libraries including LSEG libraries are preinstalled
  • The environment and its underlying configuration are managed by LSEG
  • Example notebooks are provided
  • The environment is integrated with LSEG Workspace
  • Users can begin working with the LSEG Data Library quickly
  • The environment is relatively consistent across users
  • Users do not need to manage a local virtual environment
  • CodeBook can be accessed through Workspace Web using a supported web browser

Accessing CodeBook through Workspace Web

CodeBook can also be accessed through the web version of LSEG Workspace. This allows users to work with notebooks through a supported web browser without installing the Workspace desktop application on the local computer.

The availability of CodeBook and its features depends on the user’s LSEG Workspace subscription and entitlements.

Considerations when using CodeBook

CodeBook is a managed environment. Therefore, users may have less control over:

  • The Python version
  • Installed package versions
  • Operating-system-level dependencies
  • Integration with local applications
  • Access to files stored on the local computer or network drives
  • Source control workflows, because Git is not available in CodeBook
  • External development and deployment workflows

For interactive data exploration and prototyping, these restrictions may not be important. For more customized development workflows, however, a local environment may be more appropriate.

What is a local Python environment?

A local Python environment runs on your own computer. It can use tools such as:

  • Jupyter Notebook
  • JupyterLab
  • Visual Studio Code
  • PyCharm
  • A Python script executed from a terminal
  • A virtual environment created with venv or Conda

With a local environment, you are responsible for installing Python, the LSEG Data Library, and any additional packages required by your application.

When using a Workspace Desktop Session, LSEG Workspace must be running and signed in on the same computer as the Python application.

Advantages of using a local environment

A local environment gives you more control over:

  • The Python version
  • Package versions
  • Virtual environments
  • Local and network files
  • IDE and debugger selection
  • Version control using Git and approved source-code repositories
  • Project structure
  • Integration with other applications
  • Testing and development tools
  • Script execution outside a notebook

This makes a local environment useful when moving from exploration toward a larger or more structured Python project.

Considerations when using a local environment

You are responsible for setting up and maintaining the environment. This may include:

A local environment offers flexibility, but that flexibility also introduces additional maintenance responsibilities.

CodeBook and local environment comparison

The following table summarizes the main differences.

Area CodeBook Local Python environment
Environment location Cloud-hosted environment in LSEG Workspace Runs on the user's computer
Initial setup Ready to use with minimal setup Python, packages, and development tools must be installed
Notebook interface Jupyter Notebook environment provided User selects Jupyter Notebook, JupyterLab, VS Code, PyCharm, or another tool
LSEG Data Library Available in the managed environment Must be installed and maintained by the user
Python version Managed by the CodeBook environment Selected and maintained by the user
Package management Common packages are available, customization may be limited Full control over packages and versions, subject to local IT policies
Session setup Access configuration is provided by the CodeBook environment A Workspace Desktop Session requires Workspace to be running and signed in on the same computer
File access Files can be stored in writable user folders. System folders whose names begin and end with underscores, including __Examples__, are read-only. Direct access to local files and permitted network locations
Local tools Limited integration with local applications Can integrate with local applications, command-line tools, and development workflows
IDE selection CodeBook notebook interface User can select an IDE or notebook environment
Version control Git is not available Git can be configured locally, subject to the organization’s IT and security policies
Automation Best suited to interactive use Can be integrated with approved local execution and scheduling workflows
Environment maintenance Managed by LSEG Managed by the user or the user's IT team
Troubleshooting More standardized environment May involve interpreter, dependency, proxy, certificate, or configuration issues
Best suited for Learning, exploration, training, prototypes, and ad hoc analysis Customized projects, local file workflows, development tools, testing, and integration

Important: A local Python environment does not mean that the application is automatically suitable for unattended or server-side production use. A Workspace Desktop Session depends on an active Workspace session on the same computer. Production and server-based applications may require a different access model, architecture, credentials, and licence.

Using the LSEG Data Library in CodeBook

CodeBook provides the Python environment and the access configuration required to begin using the library.

Exploring the example notebooks in CodeBook

CodeBook provides example notebooks that demonstrate how to retrieve and work with LSEG data. To access the LSEG Data Library examples, open the file browser and navigate to:

/__Examples__/01. Data Retrieval and Discovery/01.01. LSEG Data Library

You can open these notebooks, run the code, and modify the code interactively to explore different instruments, fields, and parameters.

Important: The __Examples__ folder and other system folders whose names begin and end with underscores, such as __foldername__, are read-only. You can open the notebooks, execute the code, and make temporary edits, but you cannot save changes over the original files or create new files in these folders.

To keep your changes, copy the notebook to a writable folder in your CodeBook workspace before editing it. You can then save the copied notebook and create additional files in that location.

For new development, start with the notebooks in the 01.01. LSEG Data Library folder. Examples for the Refinitiv Data Library remain available for existing notebooks and workflows, but the LSEG Data Library is recommended for new development.

A typical notebook starts by importing the library and opening a session, after the session is open, you can retrieve data using functions such as get_data() and get_history() and when you have finished working with the library, close the session:

Why CodeBook is convenient for new users

CodeBook removes many of the setup steps that users normally need to complete before running a Python notebook.

For example, users do not need to:

  • Install Python
  • Create a virtual environment
  • Install the library
  • Select a Python interpreter
  • Configure a local IDE
  • Resolve common package dependency issues before starting

This makes CodeBook a useful starting point for users who want to learn the library or validate a data request before creating a larger application.

Using the LSEG Data Library in a local environment

A local environment requires additional setup.

1. Install Python

Install a Python version supported by the current LSEG Data Library release.

A virtual environment is recommended because it isolates the packages used by the project from the global Python installation and helps prevent dependency conflicts.

For instructions on creating and using a virtual environment, see the Step-By-Step Guide to Install the Data Library for Python Using a Virtual Environment.

Using Visual Studio Code: If you plan to develop and run your project in Visual Studio Code, see the Step-By-Step Guide to Set Up a Python Development Environment in Visual Studio Code Using the LSEG Data Library. The guide covers the Python and Jupyter extensions, virtual-environment creation, interpreter selection, package installation, and installation verification.

2. Install the LSEG Data Library

Install the library from the package repository available to your organization:

Note: Some organizations use an internal Python package repository rather than public PyPI. Contact your local IT team if your environment cannot access the required package repository.

3. Start and sign in to LSEG Workspace

When using a Workspace Desktop Session, LSEG Workspace must be running and authenticated on the same computer as your Python code.
Open LSEG Workspace and confirm that you are signed in before running the notebook or script.

4. Open the Data Library session

Import the library and open the default session:

5. Test the connection

Run a small request to confirm that the environment can retrieve data:

If the request succeeds, the Data Library session and local environment are ready to use.

6. Close the session

Close the session after completing the workflow:

Running the same data request

One of the advantages of the LSEG Data Library is that the data-retrieval code can remain similar across supported environments and access points.

For example, the following request can be used after the appropriate session has been opened:

The main difference is not necessarily the get_data() call. The difference is how the surrounding Python environment and session are prepared.

In CodeBook, much of the environment is already available. Locally, you must install and maintain Python, the library, and its dependencies, while also ensuring that LSEG Workspace is running for a Workspace Desktop Session.

Moving a notebook from CodeBook to a local environment

A notebook that works in CodeBook may not always run locally without changes. Use the following checklist when moving a notebook.

1. Download the notebook

The notebooks in /__Examples__/ are read-only. Before making permanent changes, copy the required example notebook to a writable folder in your CodeBook workspace. You can then modify and save the copied notebook.

To continue working locally, download the copied .ipynb file and save it in your local project directory.

2. Create an isolated Python environment

Create a virtual environment for the project instead of installing packages into the global Python environment.

This helps prevent package conflicts and makes the project easier to maintain.

3. Install the required packages

Install the LSEG Data Library and the packages imported by the notebook.

Before moving the notebook, check the installed libraries and their versions in CodeBook. Use this information to identify the packages that may need to be installed in the local environment. However, do not automatically copy every CodeBook package. Install only the dependencies required by your notebook.

For example:

Only install packages required by the notebook. If the project will be shared or maintained over time, record the dependencies in a requirements.txt file or another dependency-management file used by your team.

For example:

4. Select the correct Python interpreter

If you use Visual Studio Code or another IDE, confirm that it is using the virtual environment where the LSEG Data Library is installed.
A common problem occurs when a package is installed in one Python environment while the notebook uses a different interpreter.
You can check the interpreter used by the notebook with:

5. Start LSEG Workspace

Before opening a Workspace Desktop Session locally, start LSEG Workspace and sign in.
The Workspace application and your Python code must run on the same computer when using this session type.

6. Review file paths

CodeBook and your local computer use different file systems. Relative or absolute paths in the notebook may therefore need to be updated.
For example, instead of using a fixed path:

consider using a path relative to the project:
Relative paths make the notebook easier to move and share.

7. Review environment-specific packages

A package available in CodeBook may not be installed locally. Similarly, a local package or operating-system dependency may not be available in CodeBook.
Check every import used by the notebook and install or replace packages as required.

8. Protect configuration and credentials

Do not store passwords, client secrets, or other sensitive values directly in a notebook or commit them to a Git repository.
If your workflow uses a configuration file, keep it outside version control where appropriate and add it to .gitignore.

For example:

Note: Whether an application key or a configuration file is required depends on the session and configuration method being used. Follow the current LSEG Data Library Quick Start and access-credentials documentation for your access point.

9. Compare the results

Run a small, representative request in both environments and compare:

  • Number of rows
  • Column names
  • Instruments returned
  • Dates
  • Missing values
  • Representative data values
  • Warnings and errors

A difference in output does not necessarily mean that one environment is incorrect. Check the installed library version, request parameters, session type, entitlements, and execution time before drawing a conclusion.

Choosing the appropriate environment

There is no single environment that is best for every user. The appropriate choice depends on the workflow.

Choose CodeBook when:

  • You want to start using the LSEG Data Library quickly
  • You do not want to install Python locally
  • You are learning Python or the Data Library
  • You are following a tutorial or attending a workshop
  • You are exploring instruments, fields, and data availability
  • You are creating a prototype or ad hoc analysis
  • Your organization restricts local software installation
  • You prefer a managed Jupyter Notebook environment
  • Your workflow does not require Git-based version control

Choose a local Python environment when:

  • You need control over Python and package versions
  • You need packages that are not available in CodeBook
  • You want to use Visual Studio Code, PyCharm, or another IDE
  • You need debugging, testing, or code-quality tools
  • You need direct access to local or permitted network files
  • You need Git for version control, collaboration, or integration with an approved source-code repository
  • You need to integrate the code with other local applications
  • You want to organize the work as a reusable Python project
  • You need to execute scripts outside an interactive notebook

Consider a different access model when:

  • The application must run without an interactive Workspace user session
  • The application will run on a server or in the cloud
  • The workflow is intended for enterprise production deployment
  • Multiple users or applications will consume the output
  • The application requires Data Platform credentials or deployed real-time infrastructure

In these cases, contact your LSEG account representative or product specialist to discuss the appropriate access point, licence, credentials, and architecture.

Entitlements and usage limits

Moving a notebook between CodeBook and a local environment does not automatically change the data that the user is entitled to access.

Data availability may depend on factors such as:

  • The user's LSEG subscription
  • Content entitlements
  • Instrument and field availability
  • The session type
  • The access point
  • The service used by the request
  • Applicable request and data-volume limits

A local environment should not be treated as a way to obtain additional quota or avoid usage controls.

When designing a recurring or high-volume workflow, review the current usage-limit documentation and test the request with a representative sample before increasing its size or frequency.

More detail can be found in articles: The Data Library for Python - Maximum Usage Reference Guide, Check LSEG Data Library for Python Usage Limits Remaining

Common questions

  • Can I use the same Python code in CodeBook and locally?
    • In many cases, the data-retrieval code can be the same. However, you may need to change environment setup, package installation, session configuration, and file paths.
  • Do I need LSEG Workspace when running locally?
    • LSEG Workspace must be running and signed in on the same computer when the local application uses a Workspace Desktop Session. Other session types have different credential and connection requirements.
  • Does running locally give me access to more data?
    • No. Running locally does not automatically change the user's subscription or content entitlements.
  • Does running locally provide more usage quota?
    • It should not be assumed that moving to a local environment provides additional quota. Applicable limits depend on the session, access point, service, and confirmed product behaviour.
  • Can I run a local script automatically?
    • A local script can be integrated with approved local automation tools. However, a Workspace Desktop Session still depends on the availability of an authenticated Workspace session. This should not be treated as equivalent to a server-side or unattended production architecture.
  • Should I develop everything in CodeBook first?
    • Not necessarily. CodeBook is useful for learning, exploration, and validating data requests. If you already know that the project requires specialized packages, local files, automated testing, Git, or integration with another system, starting in a local environment may be more efficient.
  • Will the results always be identical?
    • The same request should generally be expected to retrieve consistent data when the session, entitlements, library version, request parameters, and execution time are equivalent. However, differences may occur because of version differences, real-time data updates, session configuration, or entitlement differences.

Conclusion

CodeBook and a local Python environment both provide ways to use the LSEG Data Library for Python, but they serve different needs.
CodeBook provides a managed, cloud-hosted Jupyter Notebook environment within LSEG Workspace. It is a convenient choice for learning, interactive data exploration, training, prototyping, and users who want to begin without configuring a local development environment.
A local Python environment requires more setup and maintenance, but it provides greater control over Python packages, development tools, files, project structure, testing, and integration with other local workflows.

The choice does not need to be permanent. You can explore and validate a data workflow in CodeBook, then move it to a local environment when the project requires more control. Alternatively, you can begin locally when the workflow already depends on specific tools, packages, or files.
Whichever environment you choose, remember that the environment itself does not determine your data entitlement or guarantee additional usage capacity. Review the session type, access point, content entitlement, applicable usage limits, and deployment requirements before expanding the workflow.

For local environment setup, refer to the current LSEG Data Library Quick Start and the available virtual-environment and Visual Studio Code setup guides.

If you have questions about the LSEG Data Library, search for existing answers or post a new question in the LSEG Developer Community Q&A forum.

Request Free Trial

Request a Free Trial with the form below

Help & Support

Already a customer?

Office locations

Contact LSEG near you