Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

ImportError: No module named cm_api.api_client

ImportError: No module named cm_api.api_client

Explorer

Hi ,

 

I am following the below link to create a cluster 

 

http://blog.cloudera.com/blog/2012/09/automating-your-cluster-with-cloudera-manager-api/

 

I installed python using yum install ( python 2.6 )

 

After that from python cli i entered the below command 

 

import socket
from cm_api.api_client import ApiResource

CM_HOST = "10.xxx.xx.xxx"

api = ApiResource(CM_HOST, username="admin", password="admin")
cluster = api.create_cluster("prod01", "CDH5")

 

Its throwing the error ImportError: No module named cm_api.api_client

 

I am not able to locate the library file...

Am i missing something ?

 

Thanks,

AMRath

4 REPLIES 4

Re: ImportError: No module named cm_api.api_client

Python does not come with the CM API built in. Please install the API
separately following this document:
http://cloudera.github.io/cm_api/docs/python-client/

Regards,
Gautam Gopalakrishnan

Re: ImportError: No module named cm_api.api_client

Explorer

 Gautham,

 

Thanks very much for your help.

 

I installed and its working. Now I stuck up with some other issues .

I am trying to setup a hadoop cluster  ( CDH5 - YARN ) using cloudera manager API and python client.  Do we need to upgrade any packages (API ) ?

I am following the below link http://blog.cloudera.com/blog/2012/09/automating-your-cluster-with-cloudera-manager-api/

Is there any  other document available ?

 

 

"Role type configuration is supported only up to API v2"

 

 

>>> hdfs.update_config(
... svc_config=hdfs_service_config,
... NAMENODE=nn_config,
... DATANODE=dn_config)
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/lib/python2.6/site-packages/cm_api-8.0.0-py2.6.egg/cm_api/endpoints/services.py", line 523, in update_config
resp = self._get_resource_root().put(path, data = json.dumps(data))
File "/usr/lib/python2.6/site-packages/cm_api-8.0.0-py2.6.egg/cm_api/resource.py", line 152, in put
self._make_headers(contenttype))
File "/usr/lib/python2.6/site-packages/cm_api-8.0.0-py2.6.egg/cm_api/resource.py", line 63, in invoke
headers=headers)
File "/usr/lib/python2.6/site-packages/cm_api-8.0.0-py2.6.egg/cm_api/http_client.py", line 161, in execute
raise self._exc_class(ex)
cm_api.api_client.ApiException: Role type configuration is supported only up to API v2. (error 400)

Re: ImportError: No module named cm_api.api_client

New Contributor

Hi Gautam,

 

I am also receiving the similar Import error. However when I try to install API separately as per the document in the link you given I have received the below error. Could you please help me with this ? TIA

 

sudo pip install cm-api
Downloading/unpacking cm-api
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement cm-api
Cleaning up...
No distributions at all found for cm-api
Storing debug log for failure in /root/.pip/pip.log

Re: ImportError: No module named cm_api.api_client

New Contributor

This error is due to internet connectivity issue or pip installation issue with the server. I manually downloaded cm-api modules and installed. Working good now.