如何修复“ ImportError:无模块命名错误”

时间:2019-09-10 10:29:43

标签: elastalert

我从git clone https://github.com/Yelp/elastalert.git安装了elastalert,并与松弛工具集成在一起,但是当我尝试使用命令python -m elastalert.elastalert --verbose --rule example_frequency.yaml运行elastalert时,出现此错误:

Traceback (most recent call last):
  File "runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/dist-packages/elastalert-0.2.1-py2.7.egg/elastalert/elastalert.py", line 29, in <module>
    from . import kibana
  File "/usr/local/lib/python2.7/dist-packages/elastalert-0.2.1-py2.7.egg/elastalert/kibana.py", line 4, in <module>
    import urllib.error
ImportError: No module named error

我希望在松弛工具中获得警报的输出

1 个答案:

答案 0 :(得分:1)

我只是有同样的问题。我使用python 2.7安装elastalert。

所以我删除了elastalert并使用python36重新安装

pip uninstall elastalert
sudo yum install python36 gcc python36-devel -y 
sudo yum install python36-setuptools -y 
sudo easy_install-3.6 pip 

cd elastalert/
pip3.6 install "setuptools>=11.3"
python3.6 setup.py install
pip3.6 install -r requirements.txt
pip3.6 install elastalert

python36 -m elastalert.elastalert

希望对您或有需要的人有用