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.

centos7 hdp3.1 Metrics Monitor Start ImportError: cannot import name _common

Highlighted

centos7 hdp3.1 Metrics Monitor Start ImportError: cannot import name _common

New Contributor
running build
running build_py
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/psutil
copying psutil/__init__.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pslinux.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_common.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psposix.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_compat.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psosx.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pswindows.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_psbsd.py -> build/lib.linux-x86_64-2.7/psutil
copying psutil/_pssunos.py -> build/lib.linux-x86_64-2.7/psutil
running build_ext
building '_psutil_linux' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/psutil
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o
gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/psutil/_psutil_linux.o -L/usr/lib64 -lpython2.7 -o build/lib.linux-x86_64-2.7/_psutil_linux.so
----------------------Finished building psutil---------------------
psutil binaries need to be built by running, psutil/build.py manually or by running a, mvn clean package, command.
Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/resource_monitoring/main.py", line 28, in <module>
    from core.controller import Controller
  File "/usr/lib/python2.6/site-packages/resource_monitoring/core/controller.py", line 27, in <module>
    from metric_collector import MetricsCollector
  File "/usr/lib/python2.6/site-packages/resource_monitoring/core/metric_collector.py", line 23, in <module>
    from host_info import HostInfo
  File "/usr/lib/python2.6/site-packages/resource_monitoring/core/host_info.py", line 25, in <module>
    import psutil
  File "/usr/lib/python2.6/site-packages/resource_monitoring/psutil/build/lib.linux-x86_64-2.7/psutil/__init__.py", line 89, in <module>
    import psutil._pslinux as _psplatform
  File "/usr/lib/python2.6/site-packages/resource_monitoring/psutil/build/lib.linux-x86_64-2.7/psutil/_pslinux.py", line 20, in <module>
    from psutil import _common
ImportError: cannot import name _common
2019-02-02 09:32:49,817 - Skipping stack-select on AMBARI_METRICS because it does not exist in the stack-select package structure.
 

Command failed after 1 tries

1 REPLY 1

Re: centos7 hdp3.1 Metrics Monitor Start ImportError: cannot import name _common

Super Mentor

@Ivan Leung

Looks like at the OS level packages might be causing the conflict.

Can you please try to rebuild the "psutil" as following:

https://community.hortonworks.com/content/supportkb/150293/errorimporterror-cannot-import-name-commo...

.

Please try this to see if it works for you?

Step1). Edit the following file and then replace (comment) the line containing "from ambari_commons.subprocess32 import call" String with "from subprocess import call"

Example: (you will need to change/comment the following line)

[root@kerlatest2 resource_monitoring]# grep 'ambari_commons.subprocess' /usr/lib/python2.6/site-packages/resource_monitoring/psutil/build.py 
from ambari_commons.subprocess32 import call



After editing/commenting the mentioned line you should see it as following:

[root@kerlatest2 resource_monitoring]# grep 'subprocess' /usr/lib/python2.6/site-packages/resource_monitoring/psutil/build.py 
# from ambari_commons.subprocess32 import call
from subprocess import call 


Step2). Now rebuild the package as following:

# cd /usr/lib/python2.6/site-packages/resource_monitoring
# python psutil/build.py 




Now you should be able to ruin the AMS monitor.

Don't have an account?
Coming from Hortonworks? Activate your account here