No module named 'iotop',Python版本問題導致無法使用iotop

在Python2和Python並存的環境下,有一些使用Python2的命令稍不注意就會出現問題,例如-iotop,我也是排查es佔用io過高時才發現的問題。

[root@elk-server bin]# iotop
No module named 'iotop'
To run an uninstalled copy of iotop,
launch iotop.py in the top directory

    通過排查發現是Python環境導致的問題,開頭是-----#!/usr/bin/python,我的Python指向已經不是Python2版本了。

#!/usr/bin/python
# iotop: Display I/O usage of processes in a top like UI
# Copyright (c) 2007, 2008 Guillaume Chazarain <[email protected]>, GPLv2
# See iotop --help for some help

from __future__ import print_function
import sys

try:
    from iotop.ui import main
except ImportError as e:
    print(e)
    print('To run an uninstalled copy of iotop,')
    print('launch iotop.py in the top directory')
else:
    try:
        main()
    except KeyboardInterrupt:
        pass
    sys.exit(0)

解決:指定之前的python版本即可

vim /usr/sbin/iotop

#!/usr/bin/python2

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章