it depends on where you are running the script. If it is locally on your machine then install the cpapi as per the readme and test again.
but if it's on the management you need to be careful to follow the below instructions and make sure you add the path variable. Otherwise the script will fail.
SDK usage from a management machine
Follow the instructions above in the "Download the repository" section, to download the repository but do not run pip install .
After the downloading, copy the SDK to the machine (use scp, WinSCP or similar tool).
Configure your environment variables
export PYTHONPATH=$PYTHONPATH:<“CP-SDK” FULL PATH>
For example, if you copied the SDK to the path “/home/admin/” the command will be:
export PYTHONPATH=$PYTHONPATH:/home/admin/cp_mgmt_api_python_sdk/