From this post ‘NetApp OCI REST API and Python’ we see that it’s easy to use Python with NetApp OCI’s REST API. And this worked fine on my corporate desktop.
When I was looking in the ‘OCI REST API samples’ for Python (available for download from the OCI WebUI) - which utilizes a library to simplify access to the OCI REST API - oci_rest.py - the pre-requisites instructions include to run (from a command prompt since my desktop is Windows):
python -m pip install --requirement requirements.txt
Where requirements.txt is:
Unfortunately, running the above generates an error on my corporate desktop. Understandably, there is some corporate restriction in place that prevents me downloading the wheel files (I count myself lucky to have access to Python in the first place!)
The error I get is:
- Could not find a version that satisfies the requirement...
- No matching distribution found for requests>=2.9.0 ...
But when I run the same command on my home PC, it works and downloads 5 files as below:
- Downloading requests-2.24.0-py2.py3-none-any.whl (61 kB)
- Downloading certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
- Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
- Downloading urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
- Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Since these are not massive files, could I download them and rename them as txt files, then email in?
It is possible to download all the above files individually over the internet, but much easier for me to just use ‘pip download’ from my home PC, as below (from CMD):
python -m pip download --requirement requirements.txt
And then we’ll convert the extensions to .txt, ZIP the files, and see if we can email into the Enterprise.
Miracle of miracles, the ZIP arrives. I unzip and convert the extensions back to .whl files!
Image: NetApp OCI Python Requirements
Now to install them (again from CMD)!
Using trial and error, below is the correct order to install them:
Note: If you try to install in the order above, you’ll find some missing requirements, and see the same error as above.
- python -m pip install idna-2.10-py2.py3-none-any.whl
- python -m pip install certifi-2020.6.20-py2.py3-none-any.whl
- python -m pip install urllib3-1.25.10-py2.py3-none-any.whl
- python -m pip install chardet-3.0.4-py2.py3-none-any.whl
- python -m pip install requests-2.24.0-py2.py3-none-any.whl
YES! JOB DONE! Now to utilize the OCI REST API Python examples!
To use the NetApp OCI Python REST API examples, the first thing you'll need to do from you command line is>
python oci_rest.py install
Then in your Python shell/code, you'll want:
from oci_rest import *
Note: The above imports everything. Best practice is to be more selective.