Installation#

This quick install guide outlines the basic steps needed to install twinLab on your computer using various methods and interfaces

Requirements#

Python 3.8 to <3.12 version installed and running for your current environment.

To check your python version you can type the following into your shell:

python --version

Installation#

  1. Open a terminal:

  2. Create a directory:

Create a folder/directory where you want to install twinLab. Then, set that folder/directory as your current one.

mkdir my_project
cd my_project
  1. Install twinLab:

In your newly created directory, install twinLab (ideally in a virtual environment).

pip install twinlab

Note

We recommend managing your Python packages with Python virtual environments. See more here

  1. Configure your API key:

There are two options for configuring your API key. One involves setting a .env file on your computer which contains your API key:

Once this .env file has been set, this will enable your API key to be read from any script run in the subsequent directory tree.

echo "TWINLAB_API_KEY=<your_api_key>" > .env
echo TWINLAB_API_KEY=<your_api_key> > .env
echo "TWINLAB_API_KEY=<your_api_key>" > .env
echo "TWINLAB_API_KEY=<your_api_key>" > .env

Setting this function will enable you not to have to store your API key on your computer’s operating system.

import twinlab as tl

API_KEY = '<your_api_key>'

tl.set_api_key(API_KEY)

Warning

While we offer the flexibility to utilize the set_api_key() functionality, this should be used with care not to publicly expose your API key when sharing files.

Replace *<your_api_key>* with the API key you received with your twinLab license. (For information on licensing, please contact us here

Be aware of any blank spaces in the words between the quotation marks. This can cause errors when using twinLab.

You can check that the .env file has been created successfully using the following:

ls -a .env

You should see the .env file listed.