Install and configure the CLI
These releases of Ubuntu enforce PEP 668, which prevents you from installing Python packages system-wide using pip
. Instead, you can install using apt
or using pipx
.
If you run pip
you'll get this error:
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.12/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
Install using PipX
You can use pipx
to install the Linode CLI, system-wide in an automatically managed isolated environment.
-
Install
pipx
:sudo apt install pipx -y
-
Ensure the
pipx
path is configured:pipx ensurepath
-
Use
pipx
to install the Linode CLI:pipx install linode-cli
-
You can verify installation of the CLI by running the
--help
command:linode-cli --help
Configure the CLI
You need to authenticate your access to the CLI to use it. Use either of these methods to set it up.
Interactive configuration
With this method, you set up authentication via a token, as you initially interact with the CLI. Each time you interact with it again, you'll need to follow this same process.
-
Initiate the Linode CLI configuration process.
-
Web-based authentication: Prompts you to sign in to your account through a web browser.
linode-cli configure
-
Manually create a personal access token: Prompts you for a token that you need to manually create. See Linode API Keys and Tokens.
linode-cli configure --token
-
-
After authenticating or providing a token, you see a series of prompts to select your preferred defaults, such as the region, Compute Instance type, and distribution. These are optional and can be overridden when running individual commands. Update these defaults at any time by running
linode-cli configure
again or by editing the.config/linode-cli
configuration file.
Non-interactive configuration
To configure the CLI without any interactive prompts, you can manually generate a token and then set it using an environment variable, replacing [token]
:
export LINODE_CLI_TOKEN="[token]"
If you don't set this variable, the Linode CLI stops working until you set it again or until you set up the CLI using the interactive configuration method.
Install python and pip
If you don't already have python and pip installed on your system, follow these instructions to get the right versions.
Windows
Install Python 3 on Windows by downloading the installer package directly from Python's website:
-
Go to Python's Downloads page. Download the latest stable Python 3 package for Windows.
-
Open the installer package that was just downloaded. This is likely a
.exe
file. -
Within the installer window, check "Add Python 3.x to PATH" and then select Customize installation.
-
Ensure that the
pip
option is checked and select Next. -
Under Advanced Options, ensure that the following options are checked:
- Install for all users
- Associate files with Python
- Create shortcuts for installed applications
- Add Python to environment variables
- Precompiled standard library
-
Select
Next
to proceed with the installation. Once the installation is complete, a message appears confirming that Python 3 was successfully installed.
macOS
Install Python 3 on macOS by downloading the package directly from Python's website:
-
Go to Python's Downloads page. Download the latest stable Python 3 package for macOS.
-
Open the installer package to begin the installation.
-
Follow the prompts to install Python3 and pip.
Linux
On most Linux distributions, you can use the distribution's package manager to install both the python3
and python3-pip
packages.
-
Ubuntu and Debian: Ubuntu 22.x, 20.x, 18.x, and 16.x | Debian 11, 10, and 9
sudo apt update sudo apt install python3 && sudo apt install python3-pip
If you're using Ubuntu Linux 23.xx or later, see Linux (Ubuntu 23.xx and later) for installation instructions for
pipx
, rather than standardpip
. (These versions of Linux don't support installs usingpip
.) -
CentOS Stream, RHEL 8, and Fedora: CentOS Stream 9 (and 8), CentOS 8, other RHEL derivatives (including AlmaLinux 8, and Rocky Linux 8), and Fedora.
sudo dnf upgrade sudo dnf install python3 && sudo dnf install python3-pip
-
CentOS 7
sudo yum update sudo yum install python3 && sudo yum install python3-pip
Confirm installation
You can run any of these commands for verify installation:
python3 --version
pip3 --version
(For standardpip
)pipx --version
If you receive command not found
, you may need to add Python3, Pip3, or PipX's locations to your $PATH.
Updated about 9 hours ago