This topic describes how to install, configure, and use the Oracle Cloud Infrastructure Python SDK.
Prerequisites¶The Python SDK requires:
In addition, all Oracle Cloud Infrastructure SDKs require:
You can install the Python SDK through the Python Package Index (PyPI), GitHub, OCI Resource Manager or yum on Oracle Linux.
Set up a virtual environment¶Oracle recommends that you run the SDK in a virtual environment with virtualenv. This allows you to isolate the dependencies for the SDK and avoids any potential conflicts with other Python packages which may already be installed (e.g. in your system-wide Python).
With Linux, virtualenv is 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> source <environment name>/bin/activate
For example:
virtualenv oci_sdk_env source oci_sdk_env/bin/activatePyPi¶
To install from PyPI use the following command:
GitHub¶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 oci-*-py3-none-any.whl
Offline Installation¶Note
If youâre unable to install the whl file, make sure pip is up to date. Use
pip install -U pip
and then try to install the whl file again.
To install the Python SDK in an environment which does not allow internet connection, you can use the OCI CLI offline install files to install the Python SDK in offline mode. Here are the steps:
Go to the CLI releases page
Go to the âAssetsâ area.
Download the .zip file for your Operating System.
Copy the .zip file to the environment in which you want to install the SDK.
Unzip the .zip file. This should create a new directory called âoci-cli-installationâ.
Use the following command to install the SDK:
pip3 install oci --find-links ./oci-cli-installation/cli-deps --no-index
Installing with yum¶
If youâre using Oracle Linux 7, you can use yum to install the OCI SDK for Python.
The following example shows how to use yum to install the OCI SDK for Python 3.6:
sudo yum install python36-oci-sdk.x86_64Configuring 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.2 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.2
, run the following command to bypass the version issue:
pip install requests[security]==2.18.4
This command instructs the requests library used by the Python SDK to use the version of OpenSSL that is bundled with the cryptography library used by the SDK.
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 pythonTroubleshooting¶
You might encounter issues when installing Python or the SDK, or using the SDK itself.
Service Errors¶Any operation resulting in a service error will cause an exception of type oci.exceptions.ServiceError to be thrown by the SDK. For information about common service errors, see API Errors.
pip 10 Installation Errors¶If you are attempting to install the SDK in your system-wide Python using pip 10 then you may encounter conflicts with distutils
installed packages. An example error message is:
sudo pip install oci ... ... 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.Resolve by using a virtual environment¶
Installing the SDK in a virtual environment instead of the system-wide Python. See the Downloading and Installing the SDK section for more information
Resolve by using the system-wide Python¶If you wish to still use the system-wide Python, you can resolve this issue by downgrading the version of pip
you are using and then trying to re-install the SDK.
sudo pip install pip==9.0.3 sudo pip install oci
If you wish to stick with pip
version 10, then you will either have to install the SDK using the --user
switch:
Or you will have to uninstall the distutils installed packages manually. To do this, you will have to:
Make a note of what packages cannot be uninstalled. In the example error message, the package is requests
Find the install location for these packages. You can find this by looking in the directories returned by python -m site
One of the directories should contain a sub-directory with the same name as the package (e.g. in the case of the example error message the folder should be called requests) and a .egg-info
file which contains the package name and a version
Delete the folder and the .egg-info
file
Try and re-install the SDK:
When trying to use the SDK, if you get an exception related to SSL/TLS or certificates/certificate validation, see the command for installing requests[security] in Verify OpenSSL Version.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4