错误:包‘stomp.py’需要不同的 Python:2.7.12 不在‘>=3.6,

错误:包‘stomp.py’需要不同的 Python:2.7.12 不在‘>=3.6,

我正在尝试在我的 ubuntu 16.04 上安装ElastAlert,但每次运行时pip install elastalert都会遇到错误。我目前正在运行 python 2.7.12。任何帮助都将不胜感激。我是新手,所以不确定我做错了什么。错误消息如下:-

    DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. 
Please upgrade your Python as Python 2.7 is no longer maintained. 
pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
    Defaulting to user installation because normal site-packages is not writeable
    Collecting elastalert
      Using cached elastalert-0.2.4.tar.gz (128 kB)
    Requirement already satisfied: apscheduler>=3.3.0 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (3.6.3)
    Requirement already satisfied: aws-requests-auth>=0.3.0 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (0.4.2)
    Requirement already satisfied: blist>=1.3.6 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (1.3.6)
    Requirement already satisfied: boto3>=1.4.4 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (1.12.28)
    Requirement already satisfied: configparser>=3.5.0 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (4.0.2)
    Requirement already satisfied: croniter>=0.3.16 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (0.3.31)
    Collecting elasticsearch==7.0.0
      Using cached elasticsearch-7.0.0-py2.py3-none-any.whl (80 kB)
    Requirement already satisfied: envparse>=0.2.0 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (0.2.0)
    Requirement already satisfied: exotel>=0.1.3 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (0.1.5)
    Collecting jira>=2.0.0
      Using cached jira-2.0.0-py2.py3-none-any.whl (57 kB)
    Collecting jsonschema>=3.0.2
      Using cached jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
    Collecting mock>=2.0.0
      Using cached mock-3.0.5-py2.py3-none-any.whl (25 kB)
    Collecting prison>=0.1.2
      Using cached prison-0.1.3-py2.py3-none-any.whl (5.8 kB)
    Requirement already satisfied: PyStaticConfiguration>=0.10.3 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (0.10.4)
    Collecting python-dateutil<2.7.0,>=2.6.0
      Using cached python_dateutil-2.6.1-py2.py3-none-any.whl (194 kB)
    Requirement already satisfied: PyYAML>=3.12 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (5.3.1)
    Requirement already satisfied: requests>=2.10.0 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (2.23.0)
    Requirement already satisfied: stomp.py>=4.1.17 in /home/ubuntu/.local/lib/python2.7/site-packages (from elastalert) (6.0.0)
    ERROR: Package 'stomp.py' requires a different Python: 2.7.12 not in '>=3.6,<4.0'

答案1

错误相当明显。您尝试安装的软件包仅支持 Python 3.6+。

您的选择是安装较新的 Python(网上有大量指南)或升级到较新的 Ubuntu LTS 版本(16.04 即将终止使用)。

答案2

看起来你设法安装了较新版本的stomp.py(6.0.0)与 Python 2 不兼容,仅支持到版本 4.xx

我建议您卸载stomp.py并让其再次安装正确的版本作为依赖项。我在全新的 Ubuntu 16.04 容器中对其进行了测试,它对我来说运行良好,但请记住,您还需要最新版本的pipsetuptools才能正确构建和安装所有内容,从我尝试的情况来看:

pip install --upgrade pip
pip install --upgrade setuptools
pip uninstall stomp.py
pip install elastalert

也就是说,虽然可以elastalert在 Python 2.7 上安装,但它也兼容 Python 3(测试了 Ubuntu 16.04 的默认 3.5),这应该是可行的方法,除非您有什么特定的东西阻碍您,因为 Python 2 已被弃用并且不再支持更新。

apt install python3-pip
pip3 install elastalert

相关内容