This topic describes how to install, configure, and use the Oracle Bare Metal Cloud Services Python SDK. The Python SDK supports operations for the following services:
- Identity and Access Management Service
- Core Services (Networking Service, Compute Service, and Block Volume Service)
- Object Storage Service
- An Oracle Bare Metal Cloud Services account
- A user created in that account, in a group with a policy that grants the desired permissions. This can be a user for yourself, or another person/system that needs to call the API. For an example of how to set up a new user, group, compartment, and policy, see Adding Users in the Getting Started Guide. For a list of other typical Oracle Bare Metal Cloud Services policies, see Common Policies in the User Guide.
- Python version 2.7.5 or 3.5 or later, running on Mac, Windows, or Linux.
- The Python SDK uses the cryptography.io library, which has its own additional build requirements.
- A keypair used for signing API requests, with the public key uploaded to Oracle. Only the user calling the API should be in possession of the private key. (For more information, see Configuring the SDK.)
Downloading and Installing the SDK¶
You can install the Python SDK through the Python Package Index (PyPI), or alternatively through GitHub.
To install from PyPI:
Use the following command:pip install oraclebmc
To install from GitHub:
Download the SDK from GitHub. The download is a zip containing a whl file and documentation.
Extract the files from the zip.
Use the following command to install the SDK:
pip install oraclebmc-*-py2.py3-none-any.whl
If you're unable to install the whl file, make sure pip is up to date. Use
pip install -U pipand then try to install the whl file again.
Virtual environment (Optional)
Although optional, Oracle recommends that you run the SDK in a virtual environment with virtualenv.
With Linux, it's usually in a separate package from the main Python package. If you need to install virtualenv, use pip install virtualenv. To create and activate a virtual environment:virtualenv <environment name> . <environment name>/bin/activate
For example:virtualenv bmcs_sdk_env . bmcs_sdk_env/bin/activate
Configuring the SDK¶
Before using the SDK, you must set up your config file with the required credentials. For instructions, see SDK and Tool Configuration in the User Guide.
Verify OpenSSL Version¶
The supported version of OpenSSL for the Python SDK is version 1.0.1 or newer. Run the following command to find out the version of OpenSSL that you have:
python -c "import ssl; print(ssl.OPENSSL_VERSION)"
If the version is lower than
1.0.1, run the following command to bypass the version issue:
pip install requests[security]==2.11.1
If you don't want to use
requests[security] you can update OpenSSL as you normally would. For example, on OS X, use Homebrew to update OpenSSL using the following commands:
brew update brew install openssl brew install python
You might encounter issues when installing Python or the SDK, or using the SDK itself.
Any operation resulting in a service error will cause an exception of type oraclebmc.exceptions.ServiceError to be thrown by the SDK. For information about common service errors returned by BMCS, see API Errors .