Manual and Offline Installations

This section covers how to perform manual and offline installations of the OCI Command Line Interface (CLI):

Manual Installation

Instead of using the installation methods described in the Quickstart or using the OCI CLI Container image, you can manually install the CLI and its dependencies using pip. Before proceeding, be sure you meet the Requirements.

Prior to manually installing the CLI:

  • Make sure your Python path is set correctly
  • Run "python --version" or "python3 --version" and make sure you have the required version
  • If installing on Oracle Linux or CentOS, have the following installed:
    • gcc
    • zlib-devel
    • python3-devel
    • the latest version of OpenSSL 1.1.1
Note

You can also download the CLI installation files and perform an offline installation.

Step 1: Installing Python

Python installation instructions vary for each operating system that the CLI supports.

Note

The CLI supports only the Python versions listed in the CLI Requirements.
Windows

Install a supported version of Python from the Python Windows downloads page. During installation, choose to add Python to the PATH and/or environment variables (depending on the prompt).

Oracle Linux

Some versions of Oracle Linux come with incompatible versions of Python, and might require additional components to install the CLI. Before installing the CLI, run the following commands on a new Oracle Linux image.

Tip

The CLI is pre-installed on Oracle Linux 9, Oracle Autonomous Linux versions 7 and 8 and Oracle Linux Cloud Developer 8.
Oracle Linux 8
sudo dnf -y update
sudo dnf -y groupinstall "Development Tools"
sudo dnf -y install gcc wget openssl-devel bzip2-devel libffi-devel
sudo dnf -y module enable python36  # for Oracle Linux 8
sudo dnf -y install python36  # for Oracle Linux 8

Python is available as version-specific Application Stream modules in Oracle Linux 8 and CentOS 8.

Use dnf module list to see the currently available Python modules. For example:
$ sudo dnf module list | grep python
python36 3.6 [d] build, common [d] Python programming language, version 3.6
python38 3.8 [d] build, common [d] Python programming language, version 3.8
python39 3.9 [d] build, common [d] Python programming language, version 3.9
Then, enable and install a Python module. The following example will enable and install Python 3.9:
sudo dnf -y module enable python39
sudo dnf -y install python39
python3.9

Replace python39 and python3.9 with either python36 and python3.6 or python38 and python3.8 to install and use those versions.

Oracle Linux 7
sudo yum -y update
sudo yum -y groupinstall "Development Tools"
sudo yum -y install gcc wget openssl-devel bzip2-devel libffi-devel
sudo yum install -y python3   # for Oracle Linux 7
Note

For Oracle Linux 7, note that python3-devel is in the ol7_optional_latest repository which may not be enabled by default. To install python3-devel, run the following from a shell prompt:
sudo yum install -y --enablerepo ol7_optional_latest python3-devel

Details on how to install and use newer versions of Python that are available for Oracle Linux 7 can be found in the Oracle Linux Software Collections Library documentation.

Oracle Linux 6
Note

Oracle Linux 6 is no longer recommended. Consider using a Oracle Linux 8 instead.
sudo yum -y update
sudo yum -y groupinstall "Development Tools"
sudo yum -y install gcc wget openssl-devel bzip2-devel libffi-devel
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar xvf Python-3.6.3.tgz
cd Python-3.6*/
./configure --enable-optimizations
sudo make altinstall
CentOS

Before you install the CLI, run the following commands on a new CentOS image.

CentOS Linux 8
sudo yum -y update
sudo yum -y groupinstall "Development Tools"
sudo yum -y install gcc wget openssl-devel bzip2-devel libffi-devel
sudo dnf -y module enable python36  
sudo dnf -y install python36  

Python is available as version-specific Application Stream modules in CentOS 8.

Use dnf module list to see the currently available Python modules.

For example:
sudo dnf module list | grep python
This will produce output similar to the following:
python36 3.6 [d] build, common [d] Python programming language, version 3.6
python38 3.8 [d] build, common [d] Python programming language, version 3.8
python39 3.9 [d] build, common [d] Python programming language, version 3.9
Then, enable and install a Python module. The following example will enable and install Python 3.9:
sudo dnf -y module enable python39
sudo dnf -y install python39
python3.9

Replace python39 and python3.9 with either python36 and python3.6 or python38 and python3.8 to install and use those versions.

CentOS Linux 7
sudo yum -y update
sudo yum -y groupinstall "Development Tools"
sudo yum -y install gcc wget openssl-devel bzip2-devel libffi-devel
sudo yum install -y python3 # for CentOS Linux 7

Details on how to install and use newer versions of Python that are available for CentOS 7 can be found in the Software Collections documentation.

Ubuntu

Before you install the CLI, run the following commands on a new Ubuntu image.

Ubuntu 16, Ubuntu 18, and Ubuntu 20
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev
sudo apt update && sudo apt install python3 python3-pip python3-venv
Mac OS X

Mac OS X comes with Python pre-installed.

To install the latest version of Python on Mac OS X, see the official Python documentation.

Step 2: Creating and Configuring a Virtual Environment

The venv Python module is a virtual environment builder that lets you create isolated Python environments. We recommend installing the CLI in a virtual environment.

Installing and Activating your Virtual Environment

After Python is installed, set up a virtual environment for your operating system using the following steps.

Windows
  1. Navigate to the directory in which you would like to create the virtual environment.
  2. Create the virtual environment by running the following command:
    python -m venv oracle-cli
  3. Activate the virtual environment by running the following command:
    oracle-cli/Scripts/activate
Linux and Mac
  1. Navigate to the directory in which you would like to create the virtual environment.
  2. Create the virtual environment by running one of the following commands, depending on the version of Python installed:
    python3.8 -m venv oracle-cli
    python3.6 -m venv oracle-cli
  3. Activate the virtual environment by running the following command:
    source oracle-cli/bin/activate

Step 3: Installing the Command Line Interface

You can download the CLI from GitHub or install the package from Python Package Index (PyPI).

To install using the GitHub download:

  • Download and unzip oci-cli.zip.
  • Optionally validate the downloaded file.
  • Run the following command.

    pip install oci_cli-*-py2.py3-none-any.whl

To install using PyPI, run the following command:

pip install oci-cli

For information on how to start a CLI session, see Using the CLI.

Offline Installation

If you have a supported version of Python installed, you can perform an offline installation of the OCI CLI.

To perform an offline installation:
  1. Go to the OCI CLI release page on GitHub and select the version of the CLI that you want to install.
  2. Scroll down to the Assets section of the release page and click on the zip file to download it.
  3. Optionally validate the downloaded file.
  4. Copy the zip file to the target system.
  5. Unzip the zip file.
  6. Run the appropriate installer for the platform:
    1. On Unix and Linux, run bash install.sh --offline-install
    2. On Windows, run install.ps1 -OfflineInstall
  7. Follow the installation prompts.

For troubleshooting offline installs, see Common Issues or create an issue on GitHub.

Installing Without a Virtual Environment

We do not recommend installing the CLI in your system-wide Python and suggest that instead you install the CLI using the installer or virtual environment.

In cases where you are trying to install the CLI in your system-wide Python using the latest pip version, you might encounter conflicts with some distutils installed packages. Following is an example error message when this occurs:

sudo pip install oci-cli
...
...
Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Another option is to install the CLI for the user using the following command, although this approach is not supported:

pip install --user oci-cli

Validating the Release Checksum

After the CLI package is downloaded, you can validate the SHA-256 checksum. Depending on your operating system, use the following instructions to compare the SHA-256 value provided in Github release with the value you get when completing this procedure for your operating system.

Windows
  1. Open a command shell.
  2. Change to the directory where the download file is located.
  3. Run the following command to generate the checksum value, where filename is the name of the downloaded file on your computer:
    certutil -hashfile filename SHA256
  4. Verify that the returned checksum value matches the SHA-256 value provided in the Github release. If the values do not match, please download the file again and repeat this procedure.
Mac OS
  1. Open a terminal window.
  2. Run the following command, where fileLocation is the full path of the file on your computer:
    shasum -a 256 fileLocation 
    This command should return a checksum value.
  3. Verify that the returned checksum value matches the SHA-256 value provided in the Github release. If the values do not match, please download the file again and repeat this procedure.
Linux
  1. Open a terminal session.
  2. Run the following command, where fileLocation is the full path of the file on your computer:
    sha256sum fileLocation

    This command should return a checksum value.

  3. Verify that the returned checksum value matches the SHA-256 value provided in the Github release. If the values do not match, please download the file again and repeat this procedure.